'Duplicate identifier' 将 typescript 定义文件编译到 wwwroot 文件夹时出错
'Duplicate identifier' error when compiling typescript definition files to wwwroot folder
我创建了一个 ASP.NET 5 项目,主要用于前端打字稿应用程序。
我正在使用 grunt 和 grunt-ts 进行编译。
我有一个 'src' 文件夹,其中包含我所有的打字稿文件
grunt-ts 编译 'src' 文件夹中的所有内容,并将其合并为一个 js 文件,然后将其放入 wwwroot 文件夹中。
还生成了一个typescript定义文件,放在wwwroot文件夹下。
使用 grunt/grunt-ts 编译可以完美运行。
问题:
当 wwwroot 文件夹中存在定义文件时,visual studio IDE 开始给我很多 'Duplicate identifier' 错误。
这当然是因为定义文件。
有没有办法让 visual studio 忽略 wwwroot 文件夹(或任何文件夹),因为它是 IDE/internal typescript 编译?
Is there a way to make visual studio ignore the wwwroot folder (or any folder) for it's IDE/internal typescript compilation ?
将其从您的项目中排除。
您想将 tsconfig.json
文件添加到项目的根目录,其中包含以下内容:
{
"compilerOptions": {
"noImplicitAny": true,
"noEmitOnError": true,
"removeComments": false,
"sourceMap": false,
"module": "commonjs",
"target": "es5"
},
"exclude": [
"bower_components",
"node_modules",
"wwwroot"
]
}
tsconfig.json文件负责
配置 TypeScript 编译。
-
compilerOptions - TypeScript 到 JavaScript 编译选项。
- "noImplicitAny": true - 不允许隐式任何变量。强制明确声明它们。
- "noEmitOnError": true - 出错时停止处理。
- "removeComments": false - 不删除评论。
- "sourceMap": false - 不创建源映射文件(将其留给 gulp 插件)。
- "module": "commonjs" - 使用 Common JS 模块。
- "target": "es5" - 编译为 ECMAScript 5.
-
exclude - 从 TypeScript 扫描中排除 bower_components、node_modules 和 wwwroot 文件夹
(.ts) 或 TypeScript 定义 (.d.ts) 文件。
我创建了一个 ASP.NET 5 项目,主要用于前端打字稿应用程序。
我正在使用 grunt 和 grunt-ts 进行编译。
我有一个 'src' 文件夹,其中包含我所有的打字稿文件
grunt-ts 编译 'src' 文件夹中的所有内容,并将其合并为一个 js 文件,然后将其放入 wwwroot 文件夹中。 还生成了一个typescript定义文件,放在wwwroot文件夹下。
使用 grunt/grunt-ts 编译可以完美运行。
问题: 当 wwwroot 文件夹中存在定义文件时,visual studio IDE 开始给我很多 'Duplicate identifier' 错误。 这当然是因为定义文件。
有没有办法让 visual studio 忽略 wwwroot 文件夹(或任何文件夹),因为它是 IDE/internal typescript 编译?
Is there a way to make visual studio ignore the wwwroot folder (or any folder) for it's IDE/internal typescript compilation ?
将其从您的项目中排除。
您想将 tsconfig.json
文件添加到项目的根目录,其中包含以下内容:
{
"compilerOptions": {
"noImplicitAny": true,
"noEmitOnError": true,
"removeComments": false,
"sourceMap": false,
"module": "commonjs",
"target": "es5"
},
"exclude": [
"bower_components",
"node_modules",
"wwwroot"
]
}
tsconfig.json文件负责 配置 TypeScript 编译。
-
compilerOptions - TypeScript 到 JavaScript 编译选项。
- "noImplicitAny": true - 不允许隐式任何变量。强制明确声明它们。
- "noEmitOnError": true - 出错时停止处理。
- "removeComments": false - 不删除评论。
- "sourceMap": false - 不创建源映射文件(将其留给 gulp 插件)。
- "module": "commonjs" - 使用 Common JS 模块。
- "target": "es5" - 编译为 ECMAScript 5.
- exclude - 从 TypeScript 扫描中排除 bower_components、node_modules 和 wwwroot 文件夹 (.ts) 或 TypeScript 定义 (.d.ts) 文件。