Takichiii Takichiii - 3 months ago 12
TypeScript Question

Typescript compiler not working

I am using

tsc -w
to compile my project. I've been using it for quite a long time now but it recently stopped working after a small refactoring for (really) no reason. When I run the command, it shows me instead
tsc --help
. I didn't touch the
tsconfig.json
which is still :

{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
}
}


Did it happenned to anyone before? How can I resolve it? Thanks.

Answer

It may be that you are using a deprecated flag.

It is worth reviewing the listed options to see if you are using one that isn't listed, for example if you have:

"emitDecoratorMetadata": true,

But the help shows:

...
--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.
...

In this case, (because it is alphabetical) I can see emitDecoratorMetadata is not there and removing it should make things work.

Note: this solution should work for any case where a previously working tsc command stops working.