-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
fix(compiler-cli): enable narrowing of using type guard methods #44447
Conversation
// For calls that have a property read as receiver, we have to special-case their emit to avoid | ||
// inserting superfluous parenthesis as they prevent TypeScript from applying a narrowing effect | ||
// if the method acts as a type guard. | ||
if (receiver instanceof PropertyRead) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would we have to do the same for KeyedRead
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question, I had to check and TS doesn't seem to narrow those:
The changes in 2028c39 caused method calls to be emitted using additional parenthesis into the TCB, which in turn prevented proper type narrowing when the method acts as a type guard. This commit special-cases method calls from property reads to avoid the additional parenthesis. Fixes angular#44353
ed226d1
to
7161a74
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This PR was merged into the repository by commit 1a91218. |
The changes in 2028c39 caused method calls to be emitted using additional parenthesis into the TCB, which in turn prevented proper type narrowing when the method acts as a type guard. This commit special-cases method calls from property reads to avoid the additional parenthesis. Fixes #44353 PR Close #44447
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
The changes in 2028c39 caused method
calls to be emitted using additional parenthesis into the TCB, which in
turn prevented proper type narrowing when the method acts as a type
guard. This commit special-cases method calls from property reads to
avoid the additional parenthesis.
Fixes #44353