Skip to content
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

Bind alias ThisProperty assignment declarations #39908

Merged
merged 15 commits into from
Aug 10, 2020

Conversation

sandersn
Copy link
Member

@sandersn sandersn commented Aug 4, 2020

Fixes #39842.

This uses a pretty strict syntactic pattern to find aliases of this: var name = this (or const or let).

This is a quick prototype that does the wrong thing at the wrong time
with the wrong technique.
@typescript-bot typescript-bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Aug 4, 2020
@sandersn sandersn requested a review from uniqueiniquity August 7, 2020 23:12
@sandersn
Copy link
Member Author

sandersn commented Aug 7, 2020

This is ready to review now.

Copy link
Contributor

@uniqueiniquity uniqueiniquity left a comment

Choose a reason for hiding this comment

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

Looks good to me, but mostly from the perspective that the tests are displaying the behavior I'd expect.

@sandersn
Copy link
Member Author

@typescript-bot user test this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 10, 2020

Heya @sandersn, I've started to run the parallelized community code test suite on this PR at a6d4f35. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

The user suite test run you requested has finished and failed. I've opened a PR with the baseline diff from master.

@sandersn
Copy link
Member Author

In the user tests, all the changes are good! But there aren't as many changes as I thought there would be. I'm not convinced that it's finding all the instances of the pattern.

Copy link
Member

@andrewbranch andrewbranch left a comment

Choose a reason for hiding this comment

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

Makes sense to me

return isThisInitializedDeclaration(symbol?.valueDeclaration);
}

function getIsContextSensitiveOfThisProperty(binaryExpression: BinaryExpression, kind: AssignmentDeclarationKind) {
Copy link
Member

Choose a reason for hiding this comment

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

This string of words doesn’t grok for me, maybe because “get” and ”is” are usually mutually exclusive (though I see this is inherited from the caller), and ContextSensitive parses as “context-sensitive” (an adjective), but the “of” makes me think “context” is the noun subject and “sensitive” is the adjective we’re asking about?

Copy link
Member Author

Choose a reason for hiding this comment

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

This led to an in-person discussion in which we noticed that the parent getIsContextSensitive... function is a bad member of the getContextualTypeFor... family. I just pushed a commit that makes the whole thing return Type | undefined like the rest.

@sandersn sandersn merged commit 1ec71f0 into master Aug 10, 2020
@sandersn sandersn deleted the bind-aliased-this-property-assignments branch August 11, 2020 15:45
sandersn added a commit that referenced this pull request Aug 11, 2020
Even when `this` is aliased, which I mistakenly allowed in #39908.
sandersn added a commit that referenced this pull request Aug 11, 2020
* No this-property assignments in TS

Even when `this` is aliased, which I mistakenly allowed in #39908.

* remove errant file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Function declaration with aliased this not treated as a constructor
4 participants