【问题标题】:Typescript compiler not working打字稿编译器不工作
【发布时间】:2016-08-11 08:06:57
【问题描述】:

我正在使用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
  }
}

以前有人遇到过吗?我该如何解决?谢谢。

【问题讨论】:

  • tsc 编译器是否给出错误信息?
  • 不,不管我做什么,它只显示可能的命令

标签: typescript tsc


【解决方案1】:

可能是您使用了已弃用的标志。

值得查看列出的选项,看看您是否使用未列出的选项,例如,如果您有:

"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 命令停止工作的任何情况。

【讨论】:

  • 这个解决方案对我不起作用,但我认为它可以帮助其他人。我实际上是通过在tsconfig.json 所在的文件夹中执行命令解决了这个问题,但我想强调一个事实,即我没有更改任何内容,并且之前运行得非常好。我注意到 tsc 有很多像这样的“奇怪”错误
【解决方案2】:

只是改变

"target": "es5",

"target": "es6",

这对我有用。

【讨论】:

    猜你喜欢
    • 2013-08-19
    • 2020-03-26
    • 2018-11-13
    • 1970-01-01
    • 2017-12-16
    • 2020-04-07
    • 2017-06-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多