【发布时间】:2016-10-29 14:07:49
【问题描述】:
感谢阅读,
我有一个带有 gulp 的打字稿设置,目前使用 tsconfig 如下:
{
"files": [
"typings/index.d.ts",
"src/app/index.config.ts",
"src/app/index.constants.ts",
"src/app/common/settings.controller.ts"
....
],
"compilerOptions": {
"noImplicitAny": false,
"target": "es5",
"experimentalDecorators" : true,
"diagnostics" : true,
"rootDir" : "src/app",
"outDir": ".tmp/serve/app",
"module": "commonjs"
}
}
这是有效的,除了每次我创建另一个 ts 文件时,比如 src/app/common/login.controller.ts,我必须将它添加到上面的 "files":[] 数组中。
有没有办法让我动态地做到这一点,这样我就不必不断更新“文件”数组?
感谢您的帮助。
【问题讨论】:
-
对动态文件使用 glob?例如。
"files": [ "typings/index.d.ts", "src/app/**/*.ts" ], ... -
我试过了。 glob 似乎不起作用。它会说“找不到文件 'src/app/**/*.ts'。”
-
您根本不需要
files部分,因为您使用的是rootDir,我也使用它并且我没有files,并且我添加的每个文件都会自动编译(如只要它在rootDir下的某个地方) -
如果我完全删除“文件”,我该如何处理“typings/index.d.ts”?我得到一个巨大的错误列表 ---node_modules\typescript\lib\lib.d.ts(4874,5): error TS2300: Duplicate identifier 'xxx' 无论我是否将类型文件夹放在 src/app 中
-
在其中一个文件中包含
/// <reference path="../typings/index.d.ts" />怎么样?不确定它是否会解决它,但值得一试。
标签: angularjs typescript gulp tsconfig