Skip to content

TS4023: Exported variable 'X' has or is using name 'Y' from external module 'a/file/path' but cannot be named #5711

Closed
@janakerman

Description

@janakerman

I'm attempting to create a set of external TypeScript modules as follows:

// ClassA.ts
export default class ClassA {
  public method() { return true; } 
}

// ModuleB.ts
import ClassA from './ClassA';
var moduleB = {
  ClassA: ClassA
};
export default moduleB;

// ModuleA.ts
import moduleB from './ModuleB';
var moduleA = {
  moduleB: moduleB
}
export default moduleA;

The idea is that this will be compiled down and supplied as a library. The plan is that the consumer of the library will instantiate an instance of ClassA as follows:

import moduleA from './ModuleA';
var anInstance = moduleA.moduleB.ClassA();

This looks as though it is compiling down to the expected JS, but I'm getting an error compiler error which I'm struggling to find further information about.

Using tsc v1.6.2
.../src/ModuleA.ts(3,5): error TS4023: Exported variable 'moduleA' has or is using name 'ClassA' from external module ".../src/ClassA" but cannot be named.

Can anyone here shed any light on this issue? Does what I'm trying to do make sense?

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions