Skip to content

JSDoc implements with imported types #60591

Open
@VanillaMaster

Description

@VanillaMaster

🔎 Search Terms

Declaration emit for this file requires using private name '__type' from module '{path}'. An explicit type annotation may unblock declaration emit
implements
import
type
JSDoc

🕗 Version & Regression Information

This is the behavior in every version I tried (v5.5.4 - Nightly)

⏯ Playground Link

https://www.typescriptlang.org/play/?jsx=0&module=0&ts=5.5.4&filetype=js#code/PTAEAEDMEsBsFMB2BDAtvAXKSB7HA6AKwGcAoYAKgtNAogBcBPAB3gBN5JQBvH7PLMXoAnaIgDmoAL7TQAMTw0KwUuTBQ4SNJlAAjZMKJlKFcNFTMcw+nwU5ZkYTlSgARPmC4CJV7RXkqMwsEdER6Yh47GWVSAGNYZGIIgCEDPhBQAB4AWmzQABF4eINkemgcRFB4VGgbXGFQegALaAiYBFBheABHAFdoLoje4jFJZlEAN1L4UBR0UAByAH0lplYF-FAAQUr4AA9mWGhY2saWGeRERBx6UvLK1GRGUF7EXVgcWIBrUA5i4TuFSqNXo+BooAhXlAAF43AAWABMrgA3KQpEA

💻 Code

// @filename: foo.js
/**
 * @typedef { { foo: string } } Foo
 */

// @filename: bar.js
/**@import { Foo } from "./foo.js" */

/**@implements {Foo} */
class Bar { // <-- Declaration emit for this file requires using private name '__type'. An explicit type annotation may unblock declaration emit.
    foo = "42";
}

🙁 Actual behavior

Declaration emit for this file requires using private name '__type'. An explicit type annotation may unblock declaration emit

🙂 Expected behavior

no errors.
same code in typescript files works fine.

Additional information about the issue

if redefine type in the same file, error can be avoided

// @filename: foo.js
/**
 * @typedef { { foo: string } } Foo
 */

// @filename: bar.js
/**
 * @import { Foo } from "./foo.js"
 * @typedef { Foo } $Foo
 */

/**@implements {$Foo} */
class Bar { // <-- Ok
    foo = "42";
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions