microsoft / microsoft/TypeScript
JSDoc doesnt support generics correctly
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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