-
Notifications
You must be signed in to change notification settings - Fork 12.8k
TS doesn't narrow arrays in a union #45301
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
Comments
|
Sorry, misread the issue - maybe I'm missing something but everything seems correctly narrowed in the playground. |
Maybe OP was expecting If I'm right, this is effectively a duplicate of #42384. |
This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
Bug Report
π Search Terms
narrowing array union
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
It should correctly narrow array type as
Point[]
instead ofPoint[] | Pair[]
inprint2()
.π Expected behavior
It should have done it because I don't have a mixed type where if
a[0]
isPoint
thena[1]
could bePair
which is what I mean when I doPoint[ ] | Pair[ ]
Also this SO link could help to explain.
The text was updated successfully, but these errors were encountered: