-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Fix constant reference check in CFA #44762
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
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
x
isreadonly
. Now we also check thatobj
isn't assigned in the function body.