2

我有一个使用打字稿的 MVC 5 项目。现在我必须实现新功能,我打开其他打字稿实现方式。我正在尝试使用tsconfig.jsontypescript 1.8 的多文件新功能,我有两个文件夹:typescriptE21typescripttsconfig.json每个文件夹上都有一个文件。

首先:

{
    "compilerOptions": {
        "removeComments": false,
        "sourceMap": false,
        "target": "es5",
        "noImplicitAny": false,
        "module": "amd",
        "declaration": false,
        "noEmitOnError": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "inlineSourceMap": true,
        "inlineSources": true
    },
    "compileOnSave": true,
    "exclude": [
        "node_modules",
        "typescript"
    ]
}

第二个:

{
    "compilerOptions": {
        "removeComments": false,
        "sourceMap": false,
        "target": "es5",
        "noImplicitAny": false,
        "module": "system",
        "declaration": false,
        "noEmitOnError": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "inlineSourceMap": true,
        "inlineSources": true
    },
    "compileOnSave": true,
    "exclude": [
        "node_modules",
        "typescript21",
        "scripts"
    ]
}

当我在 Typescript 部分打开项目属性时,显示“检测到一个或多个 tsconfig.json 文件。项目属性已禁用。” 这是正确的,但是当我运行应用程序时,我收到了这个错误:

Build: Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning

在这个文件上:

import {Component} from "ngts/ngts";

@Component({
    template: `<div md-scroll-y flex class="md-padding" id="contenido">Contenido</div>`
})
export class EmAplicacion {

}

在这两个tsconfig.json文件中,我都激活了装饰器,但似乎打字稿没有从那里获得编译器选项......

另外,当我不使用装饰器时,它可以编译,但我可以看到结果文件,并且当我将“系统”放入第二个配置文件时,它们是使用 AMD 模块系统发出的......

有什么问题?

4

2 回答 2

2

真正的问题是tsconfig.json文件包含在项目中:

<None Include="typescript\tsconfig.json" />

我已经改变它;

<Content Include="typescript\tsconfig.json" />

一切都好

于 2016-03-03T07:51:04.083 回答
0

这也将有助于:

  1. 打开解决方案资源管理器
  2. 右键单击 tsconfig.json 文件并选择“从项目中排除”。
  3. 您可能会看到 tsconfig.json 从解决方案资源管理器中消失。在这种情况下,从解决方案资源管理器工具栏的顶部选择“显示所有文件”选项。
  4. 右键单击 tsconfig.json 并选择“包含在项目中”。
于 2016-08-11T06:15:09.703 回答