是否可以禁止实验装饰警告

是否可以禁止实验装饰警告

本文介绍了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标志添加到我的task.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:是否可以禁止实验装饰警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 09:16