我正在编译我的角度项目中的所有TypeScript,但是我得到了一个众所周知的错误:
error TS2300: Duplicate identifier 'require'.但是,大多数有此问题的人都会遇到这个问题,因为他们有两个文件,这会导致复制错误。在我的例子中,这是因为在相同的文件中两次使用“require”一词。
/typings/globals/angular/index.d.ts(1707,9):和
/typings/globals/angular/index.d.ts(1717,9):

它是从dt源中提取的默认角度类型定义文件。
我在本地和全球都有TypeScript。我试着删除本地副本,但错误被删除了。这是我的tsconfig.json:
{
"compilerOptions": {
"module": "commonjs",
"noImplicitAny": true,
"removeComments": true,
"preserveConstEnums": true,
"sourceMap": true
},
"files": [
"typings/index.d.ts"
]
}我的typings.json:
{
"globalDependencies": {
"angular": "registry:dt/angular#1.5.0+20160627014139",
"bootstrap": "registry:dt/bootstrap#3.3.5+20160619023404",
"jquery": "registry:dt/jquery#1.10.0+20160620094458"
}
}最后,我的主index.d.ts:
/// <reference path="globals/angular/index.d.ts" />
/// <reference path="globals/bootstrap/index.d.ts" />
/// <reference path="globals/jquery/index.d.ts" />发布于 2016-06-28 07:04:52
您不应该在d.ts文件的files部分列出tsconfig.json文件。这就是您列出需要转换到javascript中的文件的位置。您所看到的问题是由转换程序试图将您的typings/index.d.ts文件转换为javascript造成的,而它不应该这样做。类型定义实际上只是为了使代码编辑器能够提供类型提示,警告您错误,并完成代码。
看看 file。
https://stackoverflow.com/questions/38058312
复制相似问题