【发布时间】:2019-02-24 12:59:30
【问题描述】:
我的 Angular 6 应用程序中有 common-helper.ts,我接受“对装饰器的实验性支持是一项可能在未来版本中更改的功能。设置 'experimentalDecorators' 选项以删除此警告”。 我的命名约定是错误的吗?因为当我删除“-”并将文件名更改为“commonhelper.ts”时,错误正在修复。当我添加 tsconfig.json 文件“experimentalDecorators”时:true,错误没有修复。
@Injectable({
providedIn: 'root'
})
export class CommonHelper {
constructor() { }
}
}
我的 tsconfig.json 文件
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
//"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
}
}
【问题讨论】:
-
不,您的代码没有问题。只是打字稿准确地告诉您,装饰器可能会在以后更改其实现。转到 tsconfig 并将
"experimentalDecorators": true添加到您的编译器选项 -
我是从 tsconfig.json 改过来的。但这不是修复。 @ritaj
-
尝试重新编译您的项目并关闭/打开您的文本编辑器。
-
我重新编译了项目并关闭/打开文本编辑器。但仍然给我错误。我编辑了我的问题,并将我的 tsconfig.json 添加到问题@ritaj
标签: angular typescript