建造:';(';应位于*.d.ts文件中。无法编译TypeScript项目

建造:';(';应位于*.d.ts文件中。无法编译TypeScript项目,typescript,angular,Typescript,Angular,我正试图在Visual Studio 2015中构建Angular 2 TypeScript asp.net核心项目,但我看到的是: 严重性代码说明项目文件行抑制状态 错误TS1005生成:'(' 应为.MExplore C:\Users\Piotrek\documents\visualstudio 2015\Projects\MProjects\MExplore\wwwroot\lib\@angular\core\esm\src\linker\query\u list.d.ts 36 错误TS

我正试图在Visual Studio 2015中构建Angular 2 TypeScript asp.net核心项目,但我看到的是:

严重性代码说明项目文件行抑制状态 错误TS1005生成:'(' 应为.MExplore C:\Users\Piotrek\documents\visualstudio 2015\Projects\MProjects\MExplore\wwwroot\lib\@angular\core\esm\src\linker\query\u list.d.ts 36
错误TS1005生成:'(' 应为.MExplore C:\Users\Piotrek\documents\visualstudio 2015\Projects\MProjects\MExplore\wwwroot\lib\@angular\compiler\esm\src\output\output\u解释器.d.ts 7
错误TS1005生成:'(' 应为.MExplore C:\Users\Piotrek\documents\visualstudio 2015\Projects\MProjects\MExplore\wwwroot\lib\@angular\compiler\esm\src\output\output\u解释器.d.ts 8
错误TS1005生成:'(' 应为.MExplore C:\Users\Piotrek\documents\visualstudio 2015\Projects\MProjects\MExplore\wwwroot\lib\@angular\compiler\esm\src\output\output\u解释器.d.ts 9
错误TS1005生成:'(' 应为.MExplore C:\Users\Piotrek\documents\visualstudio 2015\Projects\MProjects\MExplore\wwwroot\lib\@angular\common\esm\src\forms deprecated\model.d.ts 53
错误TS1005生成:'(' 应为.MExplore C:\Users\Piotrek\documents\visualstudio 2015\Projects\MProjects\MExplore\wwwroot\lib\@angular\common\esm\src\forms deprecated\model.d.ts 98
错误TS1005生成:'(' 应为.MExplore C:\Users\Piotrek\documents\visualstudio 2015\Projects\MProjects\MExplore\wwwroot\lib\@angular\common\esm\src\forms已弃用\model.d.ts 52

等等

因此,这3743个错误的基本模式是:

生成:应为“[something]”

出现问题的文件总是以
*.d.ts
结尾

我认为这是打字的问题,但我的bootstraper(
main.ts
文件)中有适当的参考

///
以及其中的参考资料:

/// <reference path="globals/core-js/index.d.ts" />
/// <reference path="globals/jasmine/index.d.ts" />
/// <reference path="globals/node/index.d.ts" />
//
/// 
/// 
我以前用过很多次,效果很好

我还使用gulp('gulp-typescript')将typescript编译成javascript并复制到其他地方。它运行良好,没有显示错误。因此,我的代码本身可能没有问题,但我在Visual Studio中配置了错误的东西

你认为呢?

*.d.ts
文件应该被排除在编译之外。所以,基本上,这就是你在
tsconfig.json
文件中应该做的:

{
  [...]
  [some stuff]
  [...]
  "exclude": [
    "folder_where_you_have_those_faulty_files"
  ]
}

您应该从tsc building中排除一些文件夹,以*避免*编译.d.ts文件

关键的一点是,无论您使用哪种typescript版本,都不要编译*.d.ts。在您的项目中,您应该排除所有的*.d.ts编译以解决此问题


谢谢,@danny8002!

我在构建Visual Studio时收到此错误TS110 Build Typescript预期的core.d.ts。Visual Studio在构建时使用tsc-w。这会导致它构建目录下的所有文件*.ts,并且它不会区分*.d.ts和*.ts,因此将尝试编译它们。*.d.ts文件是type defne文件,无法编译。因此,您只需告诉ts忽略节点\模块文件夹

您可以通过向tsconfig.json添加以下“排除”:[“节点模块”,“键入”]。您应该始终忽略这两个文件夹

{
    "compilerOptions": {
        "module": "system",
        "noImplicitAny": true,
        "removeComments": true,
        "preserveConstEnums": true,
        "outFile": "../../built/local/tsc.js",
        "sourceMap": true
    },
    "include": [
        "src/**/*"
    ],
    "exclude": [
        "node_modules","typings"
      ]
}

但是tsconfig与CSProj是互斥的,我们如何排除CSProj中的那些文件呢!我已经在排除数组中包含了node_modules文件夹。但是它无论如何都包括它。
{
    "compilerOptions": {
        "module": "system",
        "noImplicitAny": true,
        "removeComments": true,
        "preserveConstEnums": true,
        "outFile": "../../built/local/tsc.js",
        "sourceMap": true
    },
    "include": [
        "src/**/*"
    ],
    "exclude": [
        "node_modules","typings"
      ]
}