简体   繁体   English

Visual Studio 2017 Javascript如何设置'experimentaldecorators'

[英]Visual Studio 2017 Javascript How to set 'experimentaldecorators'

Anyone knows how to get rid of this message when using Aurelia.js in VS2017?? 任何人都知道如何在VS2017中使用Aurelia.js时摆脱这条消息? 在此输入图像描述

I'm using VS2017, not VSCode, and I'm using Javascript, not Typescript as every internet article seems to believe... 我正在使用VS2017,而不是VSCode,我正在使用Javascript,而不是每个互联网文章似乎相信的Typescript ......

I tried unchecking the "Enable the new JavaScript language service" option, but it didn't help (and I also would like to keep using the new JS language service!). 我尝试取消选中“启用新的JavaScript语言服务”选项,但它没有帮助(我也想继续使用新的JS语言服务!)。

I also tried setting the EsLint option to false, but that didn't help either! 我也尝试将EsLint选项设置为false,但这也没有帮助! Any suggestions? 有什么建议?

You need a tsconfig.json with the experimentalDecorators flag set to true . 你需要一个tsconfig.json ,将experimentalDecorators标志设置为true

The reason this is here is because technical decorators haven't been accepted into ECMAScript yet (despite their wide adoption amongst many frameworks). 这是因为技术装饰器尚未被ECMAScript接受(尽管它们在许多框架中被广泛采用)。 As such its possible that this code that works today, might not be supported in the next release. 因此,今天可能运行的代码可能在下一版本中不受支持。 Because of this risk we a supply a warning anytime you use them unless otherwise acknowledged in a tsconfig file. 由于存在这种风险,我们会在您使用它们时随时提供警告,除非在tsconfig文件中另行确认。

A sample tsconfig.json that might serve you looks like this: 可能为您提供服务的示例tsconfig.json如下所示:

{
  "compilerOptions": {
    "experimentalDecorators": true, //silences the error
    "allowJs": true, // includes .js files (not just .ts)
    "noEmit": true
  },
  "exclude": [
    "node_modules" //exclude large folders with libs from project (it'll be faster)
  ],
  "typeAcquisition": {
    "enable": true  // helps fuel better js intellisense
  }
}

Let me know if that causes any additional problems. 如果这会导致任何其他问题,请告诉我。

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

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