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

Branded type does not work anymore #178

Closed
mohaalak opened this issue Jul 17, 2023 · 1 comment
Closed

Branded type does not work anymore #178

mohaalak opened this issue Jul 17, 2023 · 1 comment

Comments

@mohaalak
Copy link

Describe the bug
In the previous version of ts-pattern (prior to v5), the Branded Types feature was working correctly and as intended. However, after updating to v5.0.1, it seems that the Branded Types are no longer functioning as expected.

in (4.0.6) it's working correctly and will narrow type to primitive type when matching but after this version it needs PatternMatcher .

Code Sandbox with a minimal reproduction case
https://codesandbox.io/p/sandbox/modern-tdd-xly9tj

Versions

  • TypeScript version: 5.1.6
  • ts-pattern version: 5.0.3
  • environment: node 18
@gvergnaud
Copy link
Owner

gvergnaud commented Jul 19, 2023

Closing, is this is a duplicate of #167. Thanks for providing this sandbox link, will take a look at this shortly.

gvergnaud added a commit that referenced this issue Jul 19, 2023
TS-Pattern v4 used to support branded types, usually defined as an intersection
between a literal type (like `number` or `string`) and an object containing a unique symbol.
There is a bug in v5 that prevents people from using branded types as patterns and this PR fixes it.

This closes issue #167 and #178.
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

No branches or pull requests

2 participants