javascript - Visual Studio 2017 Javascript 如何设置 'experimentaldecorators'

标签 javascript aurelia visual-studio-2017

有人知道如何在 VS2017 中使用 Aurelia.js 时摆脱此消息吗? enter image description here

我使用的是 VS2017,而不是 VSCode,我使用的是 Javascript,而不是每篇互联网文章似乎都相信的 Typescript...

我尝试取消选中“启用新的 JavaScript 语言服务”选项,但它没有帮助(我也想继续使用新的 JS 语言服务!)。

我还尝试将 EsLint 选项设置为 false,但这也无济于事!有什么建议吗?

最佳答案

您需要将 experimentalDecorators 标志设置为 truetsconfig.json

这是因为技术装饰器还没有被 ECMAScript 接受(尽管它们在许多框架中被广泛采用)。因此,今天有效的代码可能在下一个版本中不受支持。由于存在这种风险,除非在 tsconfig 文件中另行确认,否则我们会在您使用它们时随时发出警告。

可能为您服务的示例 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
  }
}

如果这会导致任何其他问题,请告诉我。

关于javascript - Visual Studio 2017 Javascript 如何设置 'experimentaldecorators',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42853086/

相关文章:

javascript - 如何对特定位置使用 GET ELEMENT

javascript - 在 tableview 单元格中突出显示 uiwebview 文本

javascript - 使用 Aurelia cli 时如何将引导字体包括 url 从相对更改为绝对

c++ - 使用 CMake 为 VS 2017 生成解决方案的问题

c++ - C++ 中的组合练习看到速度与 VBA 相比有所下降

npm 未在 VS2017 中显示

javascript - 延长 setTimeout 计时器的超时持续时间

javascript - Promisifying Sheet API v4 导致 undefined this

javascript - 如何创建自定义属性以添加 if.bind?

dependency-injection - 我如何写入 Aurelia 中的全局变量?