-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Implement Missing Property of Type this
#14140
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
Conversation
Is this a work in progress? I don't see a test for the original case that I posted. |
Can you take a look, @mhegazy, @DanielRosenwasser ? |
…nto ImplementMissingThis
return getTypeFromTypeNode(<TypeNode>node); | ||
let typeFromTypeNode = getTypeFromTypeNode(<TypeNode>node); | ||
|
||
if (typeFromTypeNode && isExpressionWithTypeArgumentsInClassImplementsClause(node)) { |
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.
Is this the right thing to check for to find out if we are in an implements
clause?
return getTypeFromTypeNode(<TypeNode>node); | ||
let typeFromTypeNode = getTypeFromTypeNode(<TypeNode>node); | ||
|
||
if (typeFromTypeNode && isExpressionWithTypeArgumentsInClassImplementsClause(node)) { |
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.
Is this the right place to do the this instantiation or should I moce this logic into getTypeFromTypeNode
?
I created a circularity (ie: stack overflow) when I moved it even further into the checker (namely by doing the instantiation at getTypeFromTypeReference
).
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.
you can use isHeritageClauseElementIdentifier
if (typeFromTypeNode && isExpressionWithTypeArgumentsInClassImplementsClause(node)) { | ||
const containingClass = getContainingClass(node); | ||
const classType = getTypeOfNode(containingClass) as InterfaceType; | ||
typeFromTypeNode = getTypeWithThisArgument(typeFromTypeNode, classType.thisType); |
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.
consider refactoring to have one check higher up, and then handle extends/implements accordinglly
if (isHeritageClauseElementIdentifier(node)) {
const expressionWithTypearguments = <ExpressionWithTypeArguments>getAncestor(node, SyntaxKind.ExpressionWithTypeArguments);
const classDeclaration = tryGetClassExtendingExpressionWithTypeArguments(expressionWithTypearguments);
if (classDeclaration) {
// A SyntaxKind.ExpressionWithTypeArguments is considered a type node, except when it occurs in the
// extends clause of a class. We handle that case here.
return getBaseTypes(<InterfaceType>getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)))[0];
}
else {
return getTypeFromTypeNode(<TypeNode>node);
}
} |
It doesn't look like we can consolidates the checks as we discussed offline because the call to If so, we can't do the * One test case that failed is when we have In general, if we have
in which cases do we want to instantiate the EDIT: clarification |
Fixes #14104