原子打字稿找不到打字
atom-typescript can not find typings
我刚刚使用 atom-typescript 在 Atom 中配置了一个新的 Angular/Typescript 项目。该项目设置为具有一个主 angular 模块文件,该文件导入所有模块,包括类型定义文件。一切都在 gulp 中编译并且运行没有问题。
由于我使用的是 gulp,因此我已将 atom-typescript 配置为在保存时不编译 .ts 文件。现在,我在我的所有 .ts 文件中看到错误,显示 atom-typescript linter 无法找到类型。
例如:Module 'ng' has no exported member 'IScope' at line 1 col 32
我知道我可以通过为我的每个 ts 文件添加一个参考路径来解决这个问题,比如 /// <reference path="../../.tmp/typings/tsd.d.ts" />
,但这似乎真的是多余和不必要的。
由于这些错误是由 atom-typescript 引发的,有没有什么方法可以在整个项目的设置中的某个位置设置我的类型定义文件的位置?关于如何处理这个问题还有其他建议吗?
将打字放入 tsconfig.json
文件,将其他 ts 文件放入 files
条目。
因为你使用的是atom-typescript,你甚至可以使用glob patterns,即
{
...
"filesGlob": [
"./typescript/**/*.ts",
"./typescript/**/*.tsx",
"./typings/**/*.d.ts"
]
...
}
files
条目将自动更新。
编辑
由于 Typescript 现在正式支持此功能,因此更便携的解决方案(跨 IDE)可能是使用 tsconfig
的 exclude
属性。
反之亦然:编译所有内容 但 被排除的内容(通常是 node_modules
下的任何内容和 [=18= 中的静态资产])
{
"compilerOptions": {
...
},
"exclude": [
"node_modules",
"public"
]
}
官方详细信息在此 link
我刚刚使用 atom-typescript 在 Atom 中配置了一个新的 Angular/Typescript 项目。该项目设置为具有一个主 angular 模块文件,该文件导入所有模块,包括类型定义文件。一切都在 gulp 中编译并且运行没有问题。
由于我使用的是 gulp,因此我已将 atom-typescript 配置为在保存时不编译 .ts 文件。现在,我在我的所有 .ts 文件中看到错误,显示 atom-typescript linter 无法找到类型。
例如:Module 'ng' has no exported member 'IScope' at line 1 col 32
我知道我可以通过为我的每个 ts 文件添加一个参考路径来解决这个问题,比如 /// <reference path="../../.tmp/typings/tsd.d.ts" />
,但这似乎真的是多余和不必要的。
由于这些错误是由 atom-typescript 引发的,有没有什么方法可以在整个项目的设置中的某个位置设置我的类型定义文件的位置?关于如何处理这个问题还有其他建议吗?
将打字放入 tsconfig.json
文件,将其他 ts 文件放入 files
条目。
因为你使用的是atom-typescript,你甚至可以使用glob patterns,即
{
...
"filesGlob": [
"./typescript/**/*.ts",
"./typescript/**/*.tsx",
"./typings/**/*.d.ts"
]
...
}
files
条目将自动更新。
编辑
由于 Typescript 现在正式支持此功能,因此更便携的解决方案(跨 IDE)可能是使用 tsconfig
的 exclude
属性。
反之亦然:编译所有内容 但 被排除的内容(通常是 node_modules
下的任何内容和 [=18= 中的静态资产])
{
"compilerOptions": {
...
},
"exclude": [
"node_modules",
"public"
]
}
官方详细信息在此 link