【发布时间】:2019-08-25 06:10:13
【问题描述】:
这个问题与那些询问如何抑制由代码编辑器(例如 VSCode)发出的类似警告的问题不同。
我的问题是 Tsc 命令行编译器警告:
greet.ts:7:7 - 错误 TS1219:对装饰器的实验性支持是 未来版本中的功能可能会发生变化。设置 'experimentalDecorators' 选项可移除此警告。
这是我的代码:
function doMore(target) {
target.doMore = true;
}
@doMore
class Test {
do() {
console.log('done');
}
}
var t = new Test();
t.do();
console.log(t.doMore);
我在根目录下创建了以下tsconfig.json:
{
"compilerOptions": {
"experimentalDecorators": true,
"allowJs": true
}
}
但是tsc 仍然在抱怨。
【问题讨论】:
-
在这里工作正常。你确定它选择了正确的 tsconfig 吗?
-
@georg tsconfig.json 与 greet.ts 位于同一个文件夹中 - 这是我唯一的源文件。创建 tsconfig.json 后,我的 VSCode 抑制了相同的警告
-
如果你像
tsc greet.ts那样调用它,它不会使用 tsconfig... -
请告诉我如何让 tsc 使用 tsconfig.json
-
typescriptlang.org/docs/handbook/tsconfig-json.html 。基本上,在 tsconfig 中将“greet.ts”添加到
files。
标签: javascript typescript javascript-decorators