Typescript .d.ts 编译错误
Typescript .d.ts Compilation Errors
我正在使用 Visual Studio 2015 Pro 开发一个 .Net Core Angular 2 项目,使用 Systemjs 和 Kendo UI Angular 2 个组件。
我正在使用 Gulp 将库文件从 node_modules 复制到 "wwwroot/shared/lib" 并在 tsconfig.json.
中从编译中排除这两个目录
一切正常,直到我包含一个 Kendo UI 模块,这导致 typescript 编译 "node_modules/@progress/[component-name]/dist/npm/js" 目录中的 .d.ts 文件。
我在 tsconfig.json 中排除了 node_modules,所以我猜测 Kendo UI 组件代码以某种方式引用了 .d.ts 文件不知何故。
当我排除 "wwwroot" 而不是 "wwwroot/shared/lib" 时,项目编译没有错误(因为我所有的 .ts 文件都在 "wwwroot" 中)。
奇怪的是,当我将它改回 "wwwroot/shared/lib" 时,它仍然有效!但是一旦我重新启动 VS,我又得到了错误 (?!)
所有错误都特定于 "node_modules/@progress" 文件夹中的 .d.ts 文件。 "node_modules/@angular" 中有很多 .d.ts 文件不会引起任何问题,因此这必须特定于 Kendo UI 代码。
有什么方法可以阻止 VS 编译 .d.ts 文件,无论它们位于什么位置?
这是我的 tsconfig:
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
},
"compileOnSave": true,
"exclude": [
"node_modules",
"wwwroot/shared/lib"
// ,
//"wwwroot"
]
更新
看似随机,错误将从 6 跳到 149 - 包括错误 TS2304:找不到名称 'module'、'map' 等...
我试过将 "skipDefaultLibCheck": true
添加到 tsconfig 但没有成功。
添加 "types": [ "node" ]
将导致 tsc.exe 以代码 1 退出,除非我执行排除 "wwwroot" 的技巧,然后 运行 项目,然后包括再次。
在我这样做之后一切都正常 - 直到我重新启动 VS 并且一切都崩溃了。
更新 2
我为 Visual Studio 2015 (TypeScript_Dev14Full) 安装了最新版本的 Typescript,它似乎已经解决了上述大部分问题,尽管我现在遇到了一个新错误:
"TS2309 Build:An export assignment cannot be used in a module with other exported elements." 在 \node_modules\@types\node\index.d.ts
错误出现两次,一次针对项目:"TypeScript Virtual Projects" 和项目:"DevDashLocal"。
我用最新版本的 .Net Core SDK 和 Typescript 重建了项目,但在新项目中收到了同样的错误。
看来错误是由于安装了 Visual Studio 2015 的过时版本的 Typescript。更新 TS 工具删除了引用 Kendo UI
的错误
我正在使用 Visual Studio 2015 Pro 开发一个 .Net Core Angular 2 项目,使用 Systemjs 和 Kendo UI Angular 2 个组件。
我正在使用 Gulp 将库文件从 node_modules 复制到 "wwwroot/shared/lib" 并在 tsconfig.json.
中从编译中排除这两个目录一切正常,直到我包含一个 Kendo UI 模块,这导致 typescript 编译 "node_modules/@progress/[component-name]/dist/npm/js" 目录中的 .d.ts 文件。
我在 tsconfig.json 中排除了 node_modules,所以我猜测 Kendo UI 组件代码以某种方式引用了 .d.ts 文件不知何故。
当我排除 "wwwroot" 而不是 "wwwroot/shared/lib" 时,项目编译没有错误(因为我所有的 .ts 文件都在 "wwwroot" 中)。
奇怪的是,当我将它改回 "wwwroot/shared/lib" 时,它仍然有效!但是一旦我重新启动 VS,我又得到了错误 (?!)
所有错误都特定于 "node_modules/@progress" 文件夹中的 .d.ts 文件。 "node_modules/@angular" 中有很多 .d.ts 文件不会引起任何问题,因此这必须特定于 Kendo UI 代码。
有什么方法可以阻止 VS 编译 .d.ts 文件,无论它们位于什么位置?
这是我的 tsconfig:
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
},
"compileOnSave": true,
"exclude": [
"node_modules",
"wwwroot/shared/lib"
// ,
//"wwwroot"
]
更新
看似随机,错误将从 6 跳到 149 - 包括错误 TS2304:找不到名称 'module'、'map' 等...
我试过将 "skipDefaultLibCheck": true
添加到 tsconfig 但没有成功。
添加 "types": [ "node" ]
将导致 tsc.exe 以代码 1 退出,除非我执行排除 "wwwroot" 的技巧,然后 运行 项目,然后包括再次。
在我这样做之后一切都正常 - 直到我重新启动 VS 并且一切都崩溃了。
更新 2
我为 Visual Studio 2015 (TypeScript_Dev14Full) 安装了最新版本的 Typescript,它似乎已经解决了上述大部分问题,尽管我现在遇到了一个新错误:
"TS2309 Build:An export assignment cannot be used in a module with other exported elements." 在 \node_modules\@types\node\index.d.ts
错误出现两次,一次针对项目:"TypeScript Virtual Projects" 和项目:"DevDashLocal"。
我用最新版本的 .Net Core SDK 和 Typescript 重建了项目,但在新项目中收到了同样的错误。
看来错误是由于安装了 Visual Studio 2015 的过时版本的 Typescript。更新 TS 工具删除了引用 Kendo UI
的错误