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

P.select() failing to extract any type, but succeeds for all other types #301

Open
drazik opened this issue Dec 2, 2024 · 0 comments
Open

Comments

@drazik
Copy link

drazik commented Dec 2, 2024

Describe the bug

While trying to use @swan-io/boxed integration with ts-pattern, I found a case in which P.select() should extract an any value, but instead returns a parent level data structure type. This only occurs if the "selected" value is of type any. In other cases, the guessed type is OK.

You can see the original discussion on @swan-io/boxed repo, but here is the most important part:

My problem is on the line 28. I am trying to extract the Result.Ok value using P.select(), but the compiler says that this is the Result.Ok itself, instead of the value it holds.

TypeScript playground with a minimal reproduction case

Example with error: Playground

Example without error: Playground

Versions

  • TypeScript version: 5.7.2
  • ts-pattern version: 5.5.0
  • environment: Node v22.11.0
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

1 participant