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

Add const type parameters on patterns constructor #63

Merged
merged 4 commits into from
Dec 15, 2023
Merged

Add const type parameters on patterns constructor #63

merged 4 commits into from
Dec 15, 2023

Conversation

zoontek
Copy link
Contributor

@zoontek zoontek commented Dec 6, 2023

If we drop support for TypeScript < v5, we could add const type parameters on patterns constructor, which will make ts-pattern usage even more intuitive (actually, a perfect interop), as it already adopted the feature in its v5.x too.

This solves issues like this one: #62

I'm not sure it makes sense to add this to Option / Result / etc constructors, tho:

// current behavior
Option.Some("foo"); // Option<string>
Option.Some<"foo" | "bar">("foo"); // Option<"foo" | "bar">

// when adding as const type param on Some function
Option.Some("foo"); // Option<"foo">
Option.Some<"foo" | "bar">("foo"); // Option<"foo" | "bar">

PS: This PR also update dependencies and remove the legacy *.pattern object.

@bloodyowl bloodyowl merged commit ebbc808 into main Dec 15, 2023
1 check passed
@bloodyowl bloodyowl deleted the v2 branch December 15, 2023 08:53
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