microsoft / microsoft/TypeScript

Bad error when using `import()` type within JSDoc tag `@implements`

Aperta
#58,542 2 commenti 2 reazioni 1 assegnatario Vedi su GitHub

@sandersn ci sta già lavorando.

Dal 17/6/2024.

Bug Domain: JSDoc
Lingua principale
Go
Stelle
111k
Fork
14.4k
Merge medio
1g 19h
PR unite (30g)
117

Descrizione

🔎 Search Terms
  • import
  • @implements
  • 2304
🕗 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

https://www.typescriptlang.org/play/?ts=5.5.0-beta&filetype=js#code/PQKhAIAEEsFsAcA2BTWyB2AXAzuA3nPAPYBOmAFAEQCGlAlAHQBCAvuCMAFADGi12uAIL4WQA

💻 Code
/** @implements {import("a").B} */
class A {}
🙁 Actual behavior

Two TypeScript errors:

  1. Cannot find name 'import'. (2304)
  2. '}' expected. (2304)
Screenshot 2024-05-15 at 5 59 00 PM
🙂 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 {}

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.