Skip to content

Invalid type definitions generated when imported classes have same name #55375

Description

@MoonE

🔎 Search Terms

type definitions invalid name

🕗 Version & Regression Information

  • This is the behavior since TypeScript 4.0, worked in 3.9.10

⏯ Playground Link

https://github.com/MoonE/ts-types-bug

💻 Code

test/Test.js

/** @module test/Test */classTest{}exportdefaultTest;

Test.js

/** @module Test */classTest{}exportdefaultTest;

X.js

importTestfrom'./test/Test.js'/** * @typedef {Object} Options * @property {typeof import("./Test.js").default} [test] */classXextendsTest{/** * @param {Options} options */constructor(options){super();if(options.test){this.test=newoptions.test();}}}exportdefaultX;

🙁 Actual behavior

In the generate file there is a reference to a wrong class name (Test_1)

X.d.ts

exportdefaultX;exporttypeOptions={test?: typeofimport("./Test.js").default|undefined;};/** * @typedef {Object} Options * @property {typeof import("./Test.js").default} [test] */declareclassXextendsTest{/** * @param {Options} options */constructor(options: Options);test: import("./Test.js").default|undefined;}importTest_1from'./test/Test.js';//# sourceMappingURL=X.d.ts.map

🙂 Expected behavior

The class in the import statement should be named Test.

Metadata

Metadata

Labels

Fix AvailableA PR has been opened for this issueNeeds InvestigationThis issue needs a team member to investigate its status.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions