Open jaydenseric opened 5 months ago
@implements
uses the same grammar as Typescript implements. This is an error in Typescript:
class A implements import("a").B {}
However, the error is informative in typescript: "A class can only implement an identifier..." and not in Javascript. Javascript should give the same error.
With the new @import
tag, you should be able to /** @import { B } from 'a' */
instead of using @typedef
.
🔎 Search Terms
import
@implements
2304
🕗 Version & Regression Information
@implements
⏯ Playground Link
https://www.typescriptlang.org/play/?ts=5.5.0-beta&filetype=js#code/PQKhAIAEEsFsAcA2BTWyB2AXAzuA3nPAPYBOmAFAEQCGlAlAHQBCAvuCMAFADGi12uAIL4WQA
💻 Code
🙁 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: