-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Treat this
as a constant reference for purpose of narrowing using aliased expressions
#54347
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
Conversation
…liased expressions
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.
Question about a diff in an existing test.
@@ -304,9 +297,6 @@ tests/cases/conformance/controlFlow/controlFlowAliasing.ts(280,5): error TS2454: | |||
// Some narrowings may be invalidated due to later assignments. | |||
let s: string; | |||
s = this.x; | |||
~ |
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.
I would expect this to match s = x
on the next line, as it does in the previous diff. Why does the error go away for s = this.x
here, but not for s = x
?
For that matter, why does assignment in the else
branch prevent narrowing in the if
branch?
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.
There's an assignment to x
in the else
branch that causes x
to viewed as mutable and therefore it isn't narrowed. There's a comment to that effect in the test, so not unexpected.
@typescript-bot test this |
Heya @sandersn, I've started to run the perf test suite on this PR at c6ebde7. You can monitor the build here. Update: The results are in! |
Heya @sandersn, I've started to run the diff-based top-repos suite on this PR at c6ebde7. You can monitor the build here. Update: The results are in! |
Heya @sandersn, I've started to run the diff-based top-repos suite (tsserver) on this PR at c6ebde7. You can monitor the build here. Update: The results are in! |
Heya @sandersn, I've started to run the diff-based user code test suite (tsserver) on this PR at c6ebde7. You can monitor the build here. Update: The results are in! |
Hey @sandersn, I've packed this into an installable tgz. You can install it for testing by referencing it in your
and then running There is also a playground for this build and an npm module you can use via |
@@ -304,9 +297,6 @@ tests/cases/conformance/controlFlow/controlFlowAliasing.ts(280,5): error TS2454: | |||
// Some narrowings may be invalidated due to later assignments. | |||
let s: string; | |||
s = this.x; | |||
~ |
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.
There's an assignment to x
in the else
branch that causes x
to viewed as mutable and therefore it isn't narrowed. There's a comment to that effect in the test, so not unexpected.
@sandersn Here are the results of running the user test suite comparing Everything looks good! |
@sandersn Here are the results of running the top-repos suite comparing Everything looks good! |
@sandersn Here they are:
CompilerComparison Report - main..54347
System
Hosts
Scenarios
TSServerComparison Report - main..54347
System
Hosts
Scenarios
StartupComparison Report - main..54347
System
Hosts
Scenarios
Developer Information: |
@sandersn Here are the results of running the top-repos suite comparing Everything looks good! |
fixes #53267