TypeScript 编译中的实验性装饰器警告 [英] Experimental decorators warning in TypeScript compilation

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

问题描述

我收到警告...

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

Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option `to remove this warning.

...即使我在 tsconfig.json 中的 compilerOptions 具有以下设置:

... even though my compilerOptions in tsconfig.json have the following settings:

"emitDecoratorMetadata": true,
"experimentalDecorators": true,

奇怪的是,一些使用装饰器的随机类不显示该警告,但同一项目中的其余类会显示.

What is weird is that some random classes that use decorators do not show that warning but the rest in the same project do.

什么会导致 TypeScript 编译器出现这种行为?

What could cause such behavior in the TypeScript compiler?

推荐答案

尽管 VS Code 是用于 TypeScript 项目的出色编辑器,但它时不时地需要一些帮助.通常,在没有警告的情况下,某些文件会导致它惊慌失措并抱怨.大多数修复似乎是保存并关闭所有打开的文件,然后打开 tsconfig.json.之后,您应该能够重新打开有问题的文件而不会出错.如果它不起作用,请起泡,冲洗并重复.

Although VS Code is a great editor for TypeScript projects, it needs a kick every now and again. Often, without warning, certain files cause it to freak out and complain. Mostly the fix seems to be to save and close all open files, then open tsconfig.json. After that you should be able to re-open the offending file without error. If it doesn't work, lather, rinse, and repeat.

如果您的 tsconfig.json 使用 files 数组指定其源文件,则 IntelliSense 仅在相关文件被引用以便 VS Code 可以找到它时才能正常运行通过遍历输入文件树.

If your tsconfig.json specifies its source files using the files array, IntelliSense will only function correctly if the file in question is referenced such that VS Code can find it by traversing the input file tree.

重新加载窗口"命令(现在已经添加很久了)应该能一劳永逸地解决这个问题.

The 'reload window' command (added ages ago now) should solve this problem once and for all.

这篇关于TypeScript 编译中的实验性装饰器警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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