Change "isThisless" predicates to "mayReferenceThis" predicates#20036
Conversation
|
Why would we change this? |
|
It's easier to think about, "a function references this if some parameter does", than "a function is this-less if there isn't any non-this-less parameter". |
sandersn
left a comment
There was a problem hiding this comment.
I would use the naming scheme xxxReferencesThis because at some point we may make this code more complete.
| case SyntaxKind.Constructor: { | ||
| // A function-like declaration references `this` if its return type does or some parameter / type parameter does. | ||
| const fn = declaration as MethodDeclaration | MethodSignature | ConstructorDeclaration; | ||
| return (declaration.kind !== SyntaxKind.Constructor && typeMayReferenceThis(getEffectiveReturnTypeNode(fn))) |
There was a problem hiding this comment.
if getEffectiveReturnTypeNode returns undefined for nodes with SyntaxKind.Constructor, then you can skip the kind check here.
| /** A type parameter is thisless if its contraint is thisless, or if it has no constraint. */ | ||
| function isThislessTypeParameter(node: TypeParameterDeclaration) { | ||
| return !node.constraint || isThislessType(node.constraint); | ||
| return true; |
There was a problem hiding this comment.
should probably reference #20034 here too, because there are plenty of type nodes that could be inspected for this more closely.
|
Can we not merge this until we have actually discussed it? |
|
@Andy-MS @sandersn Please revert this back to the way it was. These functions were designed to return |
From code review on #19655