在使用 Angular 2 的 Meteor 应用程序中,我想创建一个自定义数据类型,如下所示:
interface MyCustomType {
index: number;
value: string;
}
然后我想在多个文件中使用这个自定义类型。我尝试创建一个名为“mycustom.type.ts”的单独文件,其中包含以下内容:
export interface MyCustomType {
index: number;
value: string;
}
然后我尝试导入这个类型,以便它可以在另一个文件中使用:
import MyCustomType from "./mycustom.type"
但是,Atom 报如下错误:
TS Error File '/.../mycustom.type.ts' is not a module ...
我应该如何声明和导入类型,以便它们可以在多个地方使用?
最佳答案
你应该像这样导入它:
import { MyCustomType } from './mycustom.type';
不要忘记 {
和 }
。
关于angular - Angular 2 中的导入接口(interface),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40720506/