microsoft / microsoft/TypeScript

JSDoc doesnt support generics correctly

Open
#56,102 5 comments 24 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Needs Proposal Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

🔎 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 :)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the api example in a .js consumer and investigate how TypeScript currently handles JSDoc generics. No specific source file or test is identified in the issue; done means JavaScript users can express and consume the T generic through JSDoc with improved developer experience.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
compilers, developer-experience
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.