-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
can't narrow from unknown
to "not a number or bigint"
#57899
Comments
I would say this is a design limitation.
|
Why isn't |
See: #39498 (comment) |
oof, ok - that issue is actually my precise need for that exact same library. That's very unfortunate. |
Consider this working code
Conceivably, type information could embed the results of |
How difficult it would be to achieve is entirely separate and not something I have knowledge of. However, I can't conceive of any code where this narrowing would be incorrect, including your example. |
This issue has been marked as "Duplicate" and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
π Search Terms
number bigint narrow
π Version & Regression Information
β― Playground Link
https://tsplay.dev/wX09ow
π» Code
π Actual behavior
errors with
Argument of type 'unknown' is not assignable to parameter of type 'string | boolean | symbol | object | null | undefined'.(2345)
π Expected behavior
passes, because the typeof check ensures that
unknown
is properly narrowed tostring | boolean | symbol | object | null | undefined
.Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: