我收到了警告…
对装饰器的实验性支持是一个在未来版本中可能会更改的特性。设置'experimentalDecorators'选项'以删除此警告。
... 即使我的编译选项在tsconfig。Json有以下设置:
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
奇怪的是,一些使用装饰器的随机类不显示警告,但同一项目中的其他类会显示警告。
在TypeScript编译器中,什么会导致这种行为?
我收到了警告…
对装饰器的实验性支持是一个在未来版本中可能会更改的特性。设置'experimentalDecorators'选项'以删除此警告。
... 即使我的编译选项在tsconfig。Json有以下设置:
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
奇怪的是,一些使用装饰器的随机类不显示警告,但同一项目中的其他类会显示警告。
在TypeScript编译器中,什么会导致这种行为?
当前回答
我在tsconfig中添加了这个选项。将前端替换为angular-cli项目的名称。
其他回答
在项目中创建文件tsconfig。Json,然后添加这些行
{
"compilerOptions": {
"experimentalDecorators": true,
"allowJs": true
}
}
为了清晰和愚蠢。
1) 打开 .vscode/settings.json。
2)添加“typescript”。Tsdk ": "node_modules/typescript/lib"
3)保存。
4)重启Visual Studio代码。
在Visual Code Studio中 进入文件>>首选项>>设置,在搜索字段中搜索“decorator”,并检查图像中的选项。
这个错误也可能意味着tsconfig.json中有错误 以我为例,我在图书馆周围移动,没有固定路径
"extends": "../../tsconfig.base.json",
修复后,错误立即消失,不需要重新启动VS Code。
在tsconfig中添加以下行。重新启动VS Code。
{
"compilerOptions": {
"experimentalDecorators": true,
"target": "es5",
"allowJs": true
}
}