有一个由Grunt编译的TypeScript项目。
我也使用JetBrains WebStorm作为IDE及其'TypeScript检查器。
问题 - 它与包含
的工作不正确<reference path="Declarations.d.ts" />
Grunt编译需要该引用,但是检查员不会将其识别为定义,并且在d.ts和TS模块中放置了大量错误:
重复标识符ClassName
如何解决?
尝试使用tsconfig文件,但在我的情况下无法使用它。
答案 0 :(得分:1)
Webstorm对TS使用<reference path>
指令,正如编译器所做的那样:)这是预期且完全有效的行为。并且在tsconfig.json
中排除引用文件确实没有帮助,因为还包括从包含文件中显式引用的文件。请参阅http://www.typescriptlang.org/docs/handbook/tsconfig-json.html:Any files that are referenced by files included via the "files" or "include" properties are also included. Similarly, if a file B.ts is referenced by another file A.ts, then B.ts cannot be excluded unless the referencing file A.ts is also specified in the "exclude" list.