Skip to content

“cannot be named” when generating declarations for re-exported classes #8612

Closed
@dakisxx

Description

@dakisxx

TypeScript Version:

1.8.10 / nightly (1.9.0-dev.20160515)

Code

// file ThingA.ts
export class ThingA { } 

// file ThingB.ts
export class ThingB { }

// file Things.ts (re-export)
export {ThingA} from "./ThingA";
export {ThingB} from "./ThingB";

// file Test.ts (uses re-exported classes)
import * as things from "./Things";

export class Test {
    public method = (input: things.ThingA)  => { };
}

// compile
tsc Test.ts --declaration --outDir compiled

Expected behavior:
No errors
Actual behavior:

Test.ts(5,5): error TS4029: Public property 'method' of exported class has or is using name 'ThingA' from external module ".../ThingA" but cannot be named.

It seems declaration file can't be generated due to the things.ThingA reference, but in a similar case without re-exporting it works fine (I will give an example of this in the next post).

If I change the import statement in Test.ts to this:

import {ThingA,ThingB} from "./Things";

(instead of import * as things) and further use ThingA directly, there are no errors, but this defeats the purpose of re-exporting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions