Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 错误TS2300:重复标识符';要求';在TypeScript编译过程中_Angularjs_Typescript_Typescript1.8 - Fatal编程技术网

Angularjs 错误TS2300:重复标识符';要求';在TypeScript编译过程中

Angularjs 错误TS2300:重复标识符';要求';在TypeScript编译过程中,angularjs,typescript,typescript1.8,Angularjs,Typescript,Typescript1.8,我正在angular项目中编译所有TypeScript,但我得到了一个众所周知的错误: error TS2300: Duplicate identifier 'require'. 但是,大多数有此问题的人都会遇到此问题,因为他们有两个导致复制错误的文件。在我的例子中,这是因为“require”一词在同一个文件中被使用了两次 /typings/globals/angular/index.d.ts(1707,9): 及 它是从dt源提取的默认角度键入定义文件 我有本地和全局的TypeScrip

我正在angular项目中编译所有TypeScript,但我得到了一个众所周知的错误:

error TS2300: Duplicate identifier 'require'.
但是,大多数有此问题的人都会遇到此问题,因为他们有两个导致复制错误的文件。在我的例子中,这是因为“require”一词在同一个文件中被使用了两次

/typings/globals/angular/index.d.ts(1707,9):

它是从dt源提取的默认角度键入定义文件

我有本地和全局的TypeScript。我试图删除本地副本,但失败了。这是我的tsconfig.json:

{
  "compilerOptions": {
    "module": "commonjs",
    "noImplicitAny": true,
    "removeComments": true,
    "preserveConstEnums": true,
    "sourceMap": true
  },
  "files": [
    "typings/index.d.ts"
  ]
}
还有my 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"
  }
}
最后是我的主要索引d.ts:

/// <reference path="globals/angular/index.d.ts" />
/// <reference path="globals/bootstrap/index.d.ts" />
/// <reference path="globals/jquery/index.d.ts" />
//
/// 
/// 

您不应该在
tsconfig.json
文件的
files
部分列出
d.ts
文件。这是您列出需要转换为javascript的已编写文件的位置。您看到的问题是由于transpiler试图将
typings/index.d.ts
文件转换为javascript而导致的,而它不应该这样做。键入定义实际上只是为了让代码编辑器能够提供类型提示、警告错误以及完成代码

看一看

/// <reference path="globals/angular/index.d.ts" />
/// <reference path="globals/bootstrap/index.d.ts" />
/// <reference path="globals/jquery/index.d.ts" />