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

ts-pattern promise handler doc or explanation on README.md #163

Open
fatihaziz opened this issue May 18, 2023 · 1 comment
Open

ts-pattern promise handler doc or explanation on README.md #163

fatihaziz opened this issue May 18, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@fatihaziz
Copy link

fatihaziz commented May 18, 2023

Is your feature request related to a problem? Please describe.
It is unsure ts-pattern support for promise handlers, because neither on the GIF, on README nor issues mentioning promise handler.
so I tried it myself,
its work, the result typing also resulting as expected, exhaustive work as expected.
https://stackblitz.com/edit/typescript-qcrlpv?file=index.ts

Describe the solution you'd like
A clear guide on README.md that the handler can be promise too.

Describe alternatives you've considered
No alternative

Additional context
I like ts-pattern as it's simpler than conventional if branches (for some use case that has complex conditional branches).
I like to make a PR to update README.md and add example too about this.

@fatihaziz fatihaziz added the enhancement New feature or request label May 18, 2023
@foot
Copy link

foot commented May 27, 2024

I've only done some limited testing with 5.0.6, but it seems like you may need to use .exhaustive or otherwise to make this work.

You can repro on the linked example, removing the exhaustive will show warnings 'await' has no effect on the type of this expression.(80007). Which is probably fine, would be worth a note if this gets added to the README.

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

No branches or pull requests

2 participants