Fix constant reference check in CFA#44762
Conversation
|
@typescript-bot perf test this |
|
Heya @ahejlsberg, I've started to run the perf test suite on this PR at d535af6. You can monitor the build here. Update: The results are in! |
|
@ahejlsberg Here they are:Comparison Report - main..44762
System
Hosts
Scenarios
Developer Information: |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
The slight performance improvement is likely from deferring more calls to @RyanCavanaugh Would be nice it we could cherry pick this fix into the 4.4 beta. |
|
If we merge this in, I'll sync the release-4.4 branch and rebuild later this afternoon with @uniqueiniquity since we have 1-2 other PRs that we want in the beta too. |
| return isConstVariable(symbol) || !!symbol.valueDeclaration && getRootDeclaration(symbol.valueDeclaration).kind === SyntaxKind.Parameter && !isParameterAssigned(symbol); | ||
| case SyntaxKind.PropertyAccessExpression: | ||
| case SyntaxKind.ElementAccessExpression: | ||
| // The resolvedSymbol property is initialized by checkPropertyAccess or checkElementAccess before we get here. |
There was a problem hiding this comment.
Would be nice if there was a way to assert this easily.
|
I added the tests case I mentioned in 3b12c04 Kind of surprised we don't narrow |
This PR is a follow up fix to #44730. The PR implements a more thorough check to ensure references are non-mutable when they are narrowed by aliased conditional expressions. For example:
Previously we'd just check that
xisreadonly. Now we also check thatobjisn't assigned in the function body.