VSCode:是否可以抑制实验性装饰器警告 [英] VSCode: Is it possible to suppress experimental decorator warnings

查看:29
本文介绍了VSCode:是否可以抑制实验性装饰器警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 VSCode 中,我收到错误:

In VSCode, I get the error:

"对装饰器的实验性支持是一项功能,在未来的版本中可能会发生变化.指定 '--experimentalDecorators' 以删除此警告."

"Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning."

我可以将 --experimentalDecorators 标志添加到我的 tasks.json 文件中以在构建时删除此错误,但我似乎无法从我的智能感知中删除它或加载 VSCode 时的错误列表.

I can add the --experimentalDecorators flag to my tasks.json file to remove this error on build, but I can't seem to remove it from my intellisense or error list when I load VSCode.

有没有办法做到这一点?

Is there a way to do this?

推荐答案

我遇到了同样的错误.我将以下 tsconfig.json 文件添加到我的项目根目录,重新启动 VSCode,它终于消失了:

I was having this same error. I added the following tsconfig.json file to my project root, restarted VSCode and it finally went away:

{
    "compilerOptions": {
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "module": "amd",
        "target": "ES6" 
    }
}

更新:

我注意到有时 VS Code 不会抑制此警告,除非您在 tsconfig.json 中添加文件"数组,即使是空数组也可以.对我来说,这现在每次都有效,如果消息没有消失,请尝试以下操作:

I've noticed that sometimes VS Code will not suppress this warning until you add a "files" array in your tsconfig.json, even an empty one will work. For me this has worked every single time now, if the message does not disappear, try the following:

{
    "compilerOptions": {
        ... 
    },
    "files": [],
    "exclude": [
        "node_modules"
    ]
}

也许这可以解释为什么每个人的结果喜忧参半?

Perhaps this will explain why everyone has mixed results?

这篇关于VSCode:是否可以抑制实验性装饰器警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆