Treat this as a constant reference for purpose of narrowing using aliased expressions#54347
Conversation
…liased expressions
sandersn
left a comment
There was a problem hiding this comment.
Question about a diff in an existing test.
| // Some narrowings may be invalidated due to later assignments. | ||
| let s: string; | ||
| s = this.x; | ||
| ~ |
There was a problem hiding this comment.
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.
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 |
| // Some narrowings may be invalidated due to later assignments. | ||
| let s: string; | ||
| s = this.x; | ||
| ~ |
There was a problem hiding this comment.
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