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. |
uniqueiniquity
left a comment
There was a problem hiding this comment.
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. |
src/compiler/checker.ts
Outdated
| return isThisInitializedDeclaration(symbol?.valueDeclaration); | ||
| } | ||
|
|
||
| function getIsContextSensitiveOfThisProperty(binaryExpression: BinaryExpression, kind: AssignmentDeclarationKind) { |
There was a problem hiding this comment.
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.
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).