-
Notifications
You must be signed in to change notification settings - Fork 26.3k
@switch can't narrow discriminate union through @let variable #61754
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
Fwiw this can be reproduced also with an
|
So it looks like this one might me be somehow a typescript issue (a bit like #59215). The TCB generates something like this
The parenthesis seems to mess up the narrowing as you can see in this playground. Edit: Upstream issue microsoft/TypeScript#61784 |
@JeanMeche well guess I need to subscribe to the typescript issue :) |
I might need to defer to @JoostK (who is so much more knowledgable on that topic) for this question. |
We add comments after each node so we can map the error back to its source. The parentheses ensure that the comment gets associated with the intended node in the AST. |
Ah that makes sense... Thanks for the explanation :) |
Indeed, that is the reason. There's some more comments, e.g. to suppress diagnostics that would have been reported elsewhere (we sometimes have to repeat certain expression) and some comments specifically for the language service to identify code. For source mapping you'd think that we could leverage source maps, and that would be a possibility except that TypeScript's |
Which @angular/* package(s) are the source of the bug?
core
Is this a regression?
No
Description
Given the following model:
In typescript we can do:
But in HTML this won't compile:
Please provide a link to a minimal reproduction of the bug
https://stackblitz.com/edit/w1mfaabm?file=src%2Fmain.ts
Please provide the exception or error you saw
Please provide the environment you discovered this bug in (run
ng version
)Anything else?
The reason for this is doing an exhaustive check in template:
The text was updated successfully, but these errors were encountered: