microsoft / microsoft/TypeScript
Bad error when using `import()` type within JSDoc tag `@implements`
Open
@sandersn is already working on this.
Since Jun 17, 2024.
Bug
Domain: JSDoc
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.4k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
Description
🔎 Search Terms
import@implements2304
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about the JSDoc tag
@implements
⏯ Playground Link
💻 Code
/** @implements {import("a").B} */
class A {}
🙁 Actual behavior
Two TypeScript errors:
Cannot find name 'import'.(2304)'}' expected.(2304)
🙂 Expected behavior
TypeScript should allow using import() types within the type of the JSDoc tag @implements.
Additional information about the issue
A workaround is to use a JSDoc @typedef to import the type under an alias, and then use that alias within the JSDoc tag @implements type, e.g:
/** @typedef {import("a").B} B */
/** @implements {B} */
class A {}
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.
Assessment
This issue has not been assessed yet.