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

查看:75
本文介绍了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中的editorOptions具有以下设置, :

... 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天全站免登陆