Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/7.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/9.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
Visual studio Visual Studio代码中存在重复标识符错误,带有Angular 2 Typescript_Visual Studio_Typescript_Angular - Fatal编程技术网

Visual studio Visual Studio代码中存在重复标识符错误,带有Angular 2 Typescript

Visual studio Visual Studio代码中存在重复标识符错误,带有Angular 2 Typescript,visual-studio,typescript,angular,Visual Studio,Typescript,Angular,我正在尝试使用Visual Studio Mac代码在Angular 2中使用Typescript设置一个组件。使用以下代码时,会出现以下错误:duplicate identifier'Component.和duplicate identifier'DashboardComponent. import {Component} from 'angular2/core'; @Component({ selector: 'dashboard', templateUrl: './dashb

我正在尝试使用Visual Studio Mac代码在Angular 2中使用Typescript设置一个组件。使用以下代码时,会出现以下错误:
duplicate identifier'Component.
duplicate identifier'DashboardComponent.

import {Component} from 'angular2/core';

@Component({
   selector: 'dashboard',
   templateUrl: './dashboard.component.html'
})

export class DashboardComponent {

}
我的文件结构如下所示:

app
-dashboard
--dashboard.component.html
--dashboard.component.ts
-app.component.html
-app.component.ts
-main.ts
index.html
{ 
    "compilerOptions": { 
    },
    "exclude": [
        "node_modules",
        "dist",
        "typings/browser.d.ts",
        "typings/browser/**"
    ]
} 
我没有将类
仪表板组件导出到代码中的任何其他位置


我不确定这是Visual Studio代码问题还是Typescript/Angular2问题。知道我做错了什么吗?

这些问题的常见原因是,您确实在项目(即项目根目录下的所有内容)的d.ts文件中的某个位置多次导出了该标识符,该文件位于文件夹结构中的深嵌套位置。为了消除这种错误,通常的方法是排除“节点模块”和(如果使用打字)“浏览器”或“主”打字文件夹,只留下一个。这是通过使用tsconfig.json的“exclude”部分完成的。话虽如此,典型的tsconfig将如下所示:

app
-dashboard
--dashboard.component.html
--dashboard.component.ts
-app.component.html
-app.component.ts
-main.ts
index.html
{ 
    "compilerOptions": { 
    },
    "exclude": [
        "node_modules",
        "dist",
        "typings/browser.d.ts",
        "typings/browser/**"
    ]
} 

希望这有帮助。

粘贴您的tsconfig.json文件。