-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Conversation
This is a quick prototype that does the wrong thing at the wrong time with the wrong technique.
Duplicative and untested, but I think I updated all the places that need updating.
This should have about the same behaviour and is much easier to understand. Also refactor common code a bit.
Once upon a time there was a parent/worker function, but now it's just a single function again. No need for the -Worker suffix.
This is ready to review now. |
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.
Looks good to me, but mostly from the perspective that the tests are displaying the behavior I'd expect.
@typescript-bot user test this |
The user suite test run you requested has finished and failed. I've opened a PR with the baseline diff from master. |
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. |
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.
Makes sense to me
return isThisInitializedDeclaration(symbol?.valueDeclaration); | ||
} | ||
|
||
function getIsContextSensitiveOfThisProperty(binaryExpression: BinaryExpression, kind: AssignmentDeclarationKind) { |
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.
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?
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.
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.
Even when `this` is aliased, which I mistakenly allowed in #39908.
* No this-property assignments in TS Even when `this` is aliased, which I mistakenly allowed in #39908. * remove errant file
Fixes #39842.
This uses a pretty strict syntactic pattern to find aliases of
this
:var name = this
(or const or let).