最新消息:20210917 已从crifan.com换到crifan.org

【已解决】VSCode中js中@observable警告:Set the experimentalDecorators option to remove this warning

JS crifan 4612浏览 0评论

折腾:

【未解决】尝试用Mobx实现ReactJS中的全局数据共享

期间,在代码中加上:

class AppGlobal {
    @observable curUserInfo = EMPTY_USER_INFO;

结果出现警告:

[js] Experimental support for decorators is a feature that is subject to change in a future release. Set the ‘experimentalDecorators’ option to remove this warning.

Set the experimentalDecorators option to remove this warning

experimentalDecorators Typescript warning always present · Issue #9335 · Microsoft/TypeScript

Getting an error for experimental support for decorators with experimentalDecorators enabled · Issue #470 · Microsoft/TypeScript-Sublime-Plugin

<a href="https://github.com/Microsoft/TypeScript/issues/10084"–<experimentalDecorators flag seemingly not accepted from tsconfig.json · Issue #10084 · Microsoft/TypeScript

How to remove experimentalDecorators warning in VSCode

【总结】

VSCode中js中添加@observable的decorator时,会报警告:

[js] Experimental support for decorators is a feature that is subject to change in a future release. Set the ‘experimentalDecorators’ option to remove this warning.

原因是

js中,装饰器时实验性的功能,以后可能会变。所以警告提示你。

想要禁止掉这个警告,可以去加上experimentalDecorators的配置。

具体做法为:

新建一个(typescript的配置文件)

tsconfig.json

内容为:

{
  “compilerOptions”: {
      “experimentalDecorators”: true,
      “allowJs”: true
  }
}

即可。 

转载请注明:在路上 » 【已解决】VSCode中js中@observable警告:Set the experimentalDecorators option to remove this warning

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
94 queries in 0.184 seconds, using 23.33MB memory