简体   繁体   English

无法在TypeScript 1.8.5中将TypeScriptExperimentalDecorators设置为True

[英]Can't set TypeScriptExperimentalDecorators to True in TypeScript 1.8.5

I downloaded a project from codeproject that demonstrates a simple working angular 2 application. 我从codeproject下载了一个项目,该项目演示了一个简单的工作angular 2应用程序。 I unblocked it, loaded it into Visual Studio 2013, and was able to successfully execute it as it. 我取消阻止它,将其加载到Visual Studio 2013中,并能够成功执行它。

I then cleaned the application and rebuilt it, and the application no compiles. 然后,我清理了应用程序并对其进行了重建,该应用程序未编译。 It outputs the error: "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." 它输出错误:“内部版本:装饰器的实验支持是一项功能,在将来的版本中可能会更改。设置'experimentalDecorators'选项可删除此警告。”

Under Visual Studio 2013, you currently need to edit the csproj file and add the entry 在Visual Studio 2013下,您当前需要编辑csproj文件并添加条目

<TypeScriptExperimentalDecorators>true</TypeScriptExperimentalDecorators>

to get it to work. 使它工作。 But under TypeScript 1.8.5 this doesn't appear to do anything. 但是在TypeScript 1.8.5下,这似乎没有任何作用。

Here's the app: First Angular2 App with TypeScript and Visual Studio 2013 这是应用程序: 具有TypeScript和Visual Studio 2013的第一个Angular2应用程序

I know that I can go into the TypeScript build tab and untick the box "Do not emit outputs if any errors are reported" and it will generate the code and run successfully, but this should be prevented for real errors, not this one. 我知道我可以进入TypeScript构建选项卡,并取消选中“如果报告任何错误,不要发出输出”框,它将生成代码并成功运行,但是对于真正的错误,而不是这个错误,应该避免使用。

Any ideas how I might get this to work in VS2013? 有什么想法可以让我在VS2013中工作吗? (I should point out, I did the same thing in VS2015 and got the same failed outcode.) (我应该指出,我在VS2015中做了同样的事情,并且得到了同样的失败代码。)

I was able to resolve this error by setting the experimentalDecorators compiler option to true in tsconfig.json. 通过在tsconfig.json中将experimentalDecorators编译器选项设置为true,我能够解决此错误。

Here I have modified an example tsconfig.json file to include this option. 在这里,我修改了一个示例tsconfig.json文件以包括此选项。

{
    "compilerOptions": {
        "module": "commonjs",
        "noImplicitAny": true,
        "removeComments": true,
        "preserveConstEnums": true,
        "outFile": "../../built/local/tsc.js",
        "sourceMap": true,
        "experimentalDecorators": true
    },
    "files": [
        "core.ts",
        "sys.ts",
        "types.ts",
        "scanner.ts",
        "parser.ts",
        "utilities.ts",
        "binder.ts",
        "checker.ts",
        "emitter.ts",
        "program.ts",
        "commandLineParser.ts",
        "tsc.ts",
        "diagnosticInformationMap.generated.ts"
    ]
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM