We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
union types narrowed incorrectly
v4.3.0-dev.20210426
Playground link with relevant code
declare function assert<T>(value: any): asserts value is T declare const foo: number | string | boolean assert<1 | string>(foo) const bar = foo //string
foo is narrowed to string
foo
string
foo should be narrowed to 1 | string
1 | string
The text was updated successfully, but these errors were encountered:
Sorry, something went wrong.
Duplicate of #31156?
See Issues with narrowing unions by union types in #32158. I think it's a design limitation?
Issues with narrowing unions by union types
instanceof
node:test
Successfully merging a pull request may close this issue.
Bug Report
π Search Terms
union types narrowed incorrectly
π Version & Regression Information
v4.3.0-dev.20210426
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
foo
is narrowed tostring
π Expected behavior
foo
should be narrowed to1 | string
The text was updated successfully, but these errors were encountered: