简体   繁体   中英

Visual Studio 2017 Javascript How to set 'experimentaldecorators'

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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