Skip to content

fix(50952): Can't infer from this type on static class method call in JS Doc #51149

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

Merged
merged 3 commits into from
Feb 1, 2023

Conversation

a-tarasyuk
Copy link
Contributor

@a-tarasyuk a-tarasyuk commented Oct 12, 2022

Fixes #50952


Not sure if TransientSymbol can be used for this (jsdoc) in the Signature context. Or better get the type directly from signature.declaration in getThisTypeOfSignature and try to instantiateType there

function getThisTypeOfSignature(signature: Signature): Type | undefined {
    if (signature.thisParameter) {
        return getTypeOfSymbol(signature.thisParameter);
    }
   // getSignatureApplicabilityError
   //   > const thisType = getThisTypeOfSignature(signature); // requires instantiated type 
   // 
    if (isInJSFile(signature.declaration)) {
        const thisTag = getJSDocThisTag(signature.declaration);
        if (thisTag && thisTag.typeExpression) {
            // like so - instantiateType(getTypeFromTypeNode(thisTag.typeExpression), signature.mapper) ?
            return getTypeFromTypeNode(thisTag.typeExpression);
        }
    }
}

@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Oct 12, 2022
Copy link
Member

@sandersn sandersn left a comment

Choose a reason for hiding this comment

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

Looks pretty good, but can you try handling @this tags in the binder to see if it works?

@sandersn sandersn self-assigned this Nov 15, 2022
@a-tarasyuk a-tarasyuk requested a review from sandersn November 16, 2022 19:49
@sandersn
Copy link
Member

sandersn commented Feb 1, 2023

Tests pass locally after merge from main.

@sandersn sandersn merged commit 42530c3 into microsoft:main Feb 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Can't infer from this type on static class method call in JS Doc
3 participants