Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve type safety of URLPattern args #105

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

nickserv
Copy link

@nickserv nickserv commented Sep 9, 2022

This makes the types closer to the behavior of the polyfill and the Chrome implementation by using a discriminated union to determine if the second arg is allowed, and then sharing the args between methods in a tuple type.

Note that this is a breaking change for TypeScript users, as I wanted to get rid of URLPatternInput to improve type safety. If possible, I'd recommend a major release for this.

@nickserv nickserv closed this Sep 9, 2022
@nickserv nickserv deleted the fix branch September 9, 2022 21:26
@nickserv nickserv restored the fix branch September 9, 2022 21:27
@nickserv nickserv reopened this Sep 9, 2022
@@ -1,11 +1,11 @@
export type URLPatternInput = URLPatternInit | string;
export type URLPatternArgs =
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we keep the name URLPatternInput to follow the spec?

@kenchris
Copy link
Owner

@SanderElias can you review this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants