我收到了警告…

对装饰器的实验性支持是一个在未来版本中可能会更改的特性。设置'experimentalDecorators'选项'以删除此警告。

... 即使我的编译选项在tsconfig。Json有以下设置:

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

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

在TypeScript编译器中,什么会导致这种行为?


当前回答

在tsconfig中添加以下行。重新启动VS Code。

{
    "compilerOptions": {
        "experimentalDecorators": true,
        "target": "es5",
        "allowJs": true
    }
}

其他回答

在tsconfig中添加以下行。重新启动VS Code。

{
    "compilerOptions": {
        "experimentalDecorators": true,
        "target": "es5",
        "allowJs": true
    }
}

我通过从tsconfig中删除"baseUrl": ""来纠正这个警告。json文件

当我创建一个新模块并移动我的*.module时,我遇到了这个错误。Ts和*-routing.module。Ts文件到另一个文件夹。在我删除了这两个文件并在新文件夹上创建了模块后,它可以完美地工作。 Angular版本9和Angular CLI版本9.1.0

在Visual Code Studio中 进入文件>>首选项>>设置,在搜索字段中搜索“decorator”,并检查图像中的选项。

File -> Preferences -> Settings