Skip to content

JSDoc doesnt support generics correctly #56102

Open
@thepassle

Description

@thepassle

🔎 Search Terms

jsdoc generics

🕗 Version & Regression Information

  • This is a crash
  • This changed between versions ______ and _______
  • This changed in commit or PR _______
  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
  • I was unable to test this on prior versions because _______

⏯ Playground Link

No response

💻 Code

Given the following code:

function api<T>(endpoint: string): Promise<T> {
  return fetch(endpoint).then(res => res.json());
}

When I consume the api function in a .js file, I'd still like to leverage the T generic via JSDoc-only. There currently isnt a straightforward way to do this, and the DX of this could definitely be improved.

🙁 Actual behavior

Cant leverage the T generic

🙂 Expected behavior

I can leverage the T generic

Additional information about the issue

This is a long overdue feature :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.SuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions