Skip to content

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

@MoonE

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 */
class Test {}
export default Test;

Test.js

/** @module Test */
class Test {}
export default Test;

X.js

import Test from './test/Test.js'

/**
 * @typedef {Object} Options
 * @property {typeof import("./Test.js").default} [test]
 */

class X extends Test {
    /**
     * @param {Options} options
     */
    constructor(options) {
        super();
        if (options.test) {
            this.test = new options.test();
        }
    }
}

export default X;

πŸ™ Actual behavior

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

X.d.ts

export default X;
export type Options = {
    test?: typeof import("./Test.js").default | undefined;
};
/**
 * @typedef {Object} Options
 * @property {typeof import("./Test.js").default} [test]
 */
declare class X extends Test {
    /**
     * @param {Options} options
     */
    constructor(options: Options);
    test: import("./Test.js").default | undefined;
}
import Test_1 from './test/Test.js';
//# sourceMappingURL=X.d.ts.map

πŸ™‚ Expected behavior

The class in the import statement should be named Test.

Metadata

Metadata

Assignees

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