打字稿编译器不工作
Typescript compiler not working
我正在使用 tsc -w
来编译我的项目。我已经使用它很长时间了,但它最近在(真的)无缘无故地进行了小规模重构后停止工作。当我 运行 命令时,它显示我 tsc --help
。我没有碰 tsconfig.json
,它仍然是 :
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
}
}
以前有人遇到过吗?我该如何解决?谢谢
可能是您使用了已弃用的标志。
值得查看列出的选项,看看您是否正在使用未列出的选项,例如,如果您有:
"emitDecoratorMetadata": true,
但是帮助显示:
...
--allowUnusedLabels Do not report errors on unused labels.
-d, --declaration Generates corresponding '.d.ts' file.
--experimentalDecorators Enables experimental support for ES7 decorators.
--forceConsistentCasingInFileNames Disallow inconsistently-cased references to the same file.
...
在这种情况下,(因为它是按字母顺序排列的)我可以看到 emitDecoratorMetadata
不存在,删除它应该可以正常工作。
注意:此解决方案应该适用于以前工作的 tsc
命令停止工作的任何情况。
改变一下
"target": "es5",
至
"target": "es6",
这对我有用。
我正在使用 tsc -w
来编译我的项目。我已经使用它很长时间了,但它最近在(真的)无缘无故地进行了小规模重构后停止工作。当我 运行 命令时,它显示我 tsc --help
。我没有碰 tsconfig.json
,它仍然是 :
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
}
}
以前有人遇到过吗?我该如何解决?谢谢
可能是您使用了已弃用的标志。
值得查看列出的选项,看看您是否正在使用未列出的选项,例如,如果您有:
"emitDecoratorMetadata": true,
但是帮助显示:
...
--allowUnusedLabels Do not report errors on unused labels.
-d, --declaration Generates corresponding '.d.ts' file.
--experimentalDecorators Enables experimental support for ES7 decorators.
--forceConsistentCasingInFileNames Disallow inconsistently-cased references to the same file.
...
在这种情况下,(因为它是按字母顺序排列的)我可以看到 emitDecoratorMetadata
不存在,删除它应该可以正常工作。
注意:此解决方案应该适用于以前工作的 tsc
命令停止工作的任何情况。
改变一下
"target": "es5",
至
"target": "es6",
这对我有用。