Skip to content

Reimplement #20320 differently to handle multiple check orders better#20588

Merged
weswigham merged 2 commits into
microsoft:masterfrom
weswigham:fix-improt-alias-const-refs
Dec 11, 2017
Merged

Reimplement #20320 differently to handle multiple check orders better#20588
weswigham merged 2 commits into
microsoft:masterfrom
weswigham:fix-improt-alias-const-refs

Conversation

@weswigham
Copy link
Copy Markdown
Member

This should fix the remaining RWC breaks @sandersn mentioned (verified - the only changes in the affected tests with this change are error message changes from the changes to contextual literal types).

Now, instead of collecting the referenced status prior to checking the LHS, then resetting it (which could fail if the LHS didn't already have a resolved symbol, which was the issue), now this simply disables reference marking for identifiers which are the LHS of a property access expression, and instead does the reference marking for such nodes' symbols inside checkPropertyAccxessExpressionOrQualifiedName. This is less general (it can't handle eliding when there are arbitrary non-identifier LHS productions), but covers the common (reported) usecase.

@weswigham weswigham requested review from mhegazy and sandersn December 9, 2017 00:14
@weswigham weswigham changed the title Reimplement #20320 less elegantly to handle multiple check orders better Reimplement #20320 differently to handle multiple check orders better Dec 9, 2017
Copy link
Copy Markdown
Member

@sandersn sandersn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look *that clunky, and I like the elimination of the scary "Reset the referenced-ness" code.

Comment thread src/compiler/checker.ts Outdated
const assignmentKind = getAssignmentTargetKind(node);
const prop = getPropertyOfType(apparentType, right.escapedText);
if (!prop) {
if (isIdentifier(left) && parentSymbol) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it read better to lift this check out if the prop/!prop if? Put it afterwards, as:

if (isIdentifier(left) && parentSymbol && (!prop || !isConstEnumOrConstEnumOnlyModule(prop))) ...

(and it would probably read better to invert the !prop/prop if, but that's out of scope here)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably, considering it's repeated before all exit points of the function.

@weswigham weswigham merged commit d01f4d1 into microsoft:master Dec 11, 2017
@weswigham weswigham deleted the fix-improt-alias-const-refs branch December 11, 2017 18:32
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants