Skip to content
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

unused type parameter message is wrong for jsdoc @template #32843

Closed
sandersn opened this issue Aug 13, 2019 · 3 comments · Fixed by #33320
Closed

unused type parameter message is wrong for jsdoc @template #32843

sandersn opened this issue Aug 13, 2019 · 3 comments · Fixed by #33320
Labels
Bug A bug in TypeScript Domain: JSDoc Relates to JSDoc parsing and type generation Domain: Quick Fixes Editor-provided fixes, often called code actions. Good First Issue Well scoped, documented and has the green light
Milestone

Comments

@sandersn
Copy link
Member

sandersn commented Aug 13, 2019

/**
 * @template {string} K
 * @template V
 */
class MM {
    constructor() {
        /** @type {V} */
        this.t;
    }
}

Expected behavior:
Message: "K is declared but its value is never read"

Actual behavior:
Message: "All type parameters are unused."

Note that the message is the same if K comes second. The code in checkUnusedTypeParameters looks suspicious where it tries to handle template tags, so it's probably just wrong.

@sandersn sandersn added this to the Backlog milestone Aug 13, 2019
@sandersn sandersn added Bug A bug in TypeScript Domain: JSDoc Relates to JSDoc parsing and type generation Domain: Quick Fixes Editor-provided fixes, often called code actions. labels Aug 13, 2019
@sandersn sandersn changed the title unused type parameter message is wrong from jsdoc @template unused type parameter message is wrong for jsdoc @template Aug 13, 2019
@sandersn sandersn added the Good First Issue Well scoped, documented and has the green light label Aug 13, 2019
@rbrishabh
Copy link

Hey! I would like to take this up!

@princeseth
Copy link

Hi @sandersn — I've tried to debug this and found that isReferenced property of Symbol object remains undefined for every TypeParameter. Due to this isTypeParameterUnused function always return true for each parameters.
Could you please give some reference where I can initialize isReferenced property of SymbolObject.?
Thanks

@sandersn
Copy link
Member Author

sandersn commented Sep 4, 2019

isReferenced is basically only modified in resolveName[Helper]. When the compiler checks /** @type {V} */, it should call resolveName on V, which should then mark it as used.

I'd put a breakpoint in resolveTypeReferenceName and see why resolving V doesn't end up setting isReferenced.

pr1tkin pushed a commit to pr1tkin/TypeScript that referenced this issue Sep 9, 2019
…arameter are unused for jsdoc `@template`
andrewbranch pushed a commit that referenced this issue Mar 31, 2020
…are unused for jsdoc `@template` (#33320)

Co-authored-by: magierjones <simon.jaeger@magierjones.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: JSDoc Relates to JSDoc parsing and type generation Domain: Quick Fixes Editor-provided fixes, often called code actions. Good First Issue Well scoped, documented and has the green light
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants