Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Typescript中正确导入模块?_Typescript_Typescript2.0 - Fatal编程技术网

如何在Typescript中正确导入模块?

如何在Typescript中正确导入模块?,typescript,typescript2.0,Typescript,Typescript2.0,} 我尝试在组件中导入此模块,如: I have a declared module: declare module conflicts { export interface Item {} export interface Item2 {} export interface Item3 {} 然后使用它: import * from '../../../_models/conflicts/conflicts'; 但它不起作用模块声明应如下所示: let c = {} a

}

我尝试在组件中导入此模块,如:

I have a declared module:

declare module conflicts {

  export interface Item {}

  export interface Item2 {}

  export interface Item3 {}
然后使用它:

import * from '../../../_models/conflicts/conflicts';

但它不起作用

模块声明应如下所示:

let c = {} as conflicts.item3;
进口应为:

import*作为来自“../../../../\u模型/冲突/冲突”的冲突

然后,要使用导入,请执行以下操作:

将c={}设为conflicts.conflicts.Item3

注:

  • 与用法中的小写字母“c”冲突
    基本上是 进口货物的内容
  • 与用法中的大写字母“C”冲突
    是模块本身
  • 确保将“Item3”的“I”大写为 匹配模块中的接口声明
  • 在导入的
    as conflicts
    部分中,您确实可以将
    conflicts
    更改为您想要的任何内容。这只是为了设置如何在文件的其余部分引用导入

应该是:
导出声明模块冲突{}
请不要发布您认为有效的答案。如果你现在不测试,试着把它写下来作为评论。谢谢你的反馈,@pinkiewirl。我现在已经测试了我的解决方案并进行了一些更正。在我将来发布答案之前,我一定会这样做。
export declare module Conflicts {

  export interface Item {}

  export interface Item2 {}

  export interface Item3 {}
}