-
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
typeof type narrowing acts differently with equivalent parentheses grouping #42203
Comments
Narrowings only occur on predefined syntactic patterns, and this isn't one of them. I could see wanting to add parens here for clarity, though -- we should detect this one too. |
(can I delete the above referenced commits from this thread? I put an incorrect issue reference in the commit message and it was destined for another; I do not want to pollute the repo / resolved issue list) |
I don't know a way to do that. I wouldn't worry about it. |
Any chance of this to be ever fixed? It causes bigger problems in angular/angular#59215 |
@Andarist seems like something you might be interested to do? |
Expect a PR on your desk by tomorrow morning 🫡 |
Bug Report
Type narrowing using the typeof operator seems to act differently if an early parenthesis grouping is used.
🔎 Search Terms
type narrowing typeof parentheses
🕗 Version & Regression Information
4.1.3
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
In the second case,
foo
isn't narrowed to typenever
.🙂 Expected behavior
In the second case,
foo
is narrowed to typenever
.The text was updated successfully, but these errors were encountered: