【发布时间】:2016-04-04 14:12:33
【问题描述】:
我无法导入已导出两次的类。
a.ts
import * as moduleB from "./b";
export class A {
b: moduleB.B;
constructor() {
this.b = new moduleB.B();
this.b.hello();
}
}
b.ts
import {C} from "./c";
export const B = C;
c.ts
export class C {
hello() {
console.log("hello");
}
}
错误信息是:
a.ts(3,14): error TS2305: Module '"b"' has no exported member 'B'.
问题似乎是C的类型可能没有用“export const B = C;”导出。如果我更改“b:moduleB.B;”,错误就会消失只是“b:任何;”。 我该如何解决这个问题?
在 b.ts 中使用默认导出会起作用,但我想在 b.ts 中导出几个东西,所以这不是一个选项。我正在使用 Typescript 1.7.5。
【问题讨论】:
标签: typescript