Visual Studio 2017 Javascript How to set 'experimentaldecorators'

霸气de小男生 提交于 2020-01-04 02:45:14

问题


Anyone knows how to get rid of this message when using Aurelia.js in VS2017??

I'm using VS2017, not VSCode, and I'm using Javascript, not Typescript as every internet article seems to believe...

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!).

I also tried setting the EsLint option to false, but that didn't help either! Any suggestions?


回答1:


You need a tsconfig.json with the experimentalDecorators flag set to true.

The reason this is here is because technical decorators haven't been accepted into ECMAScript yet (despite their wide adoption amongst many frameworks). 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.

A sample tsconfig.json that might serve you looks like this:

{
  "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.



来源:https://stackoverflow.com/questions/42853086/visual-studio-2017-javascript-how-to-set-experimentaldecorators

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!