target in tsconfig.json setting not working but command works?

Viewed 623
{
  "compilerOptions": {
    "target": "es5"
  }
}

I have tsconfig.json as above, and when I run command tsc app.ts --watch, I hit error

Accessors are only available when targeting ECMAScript 5 and higher

If I explicitly set the target in my command, it works

tsc -t es5 app.ts --watch

Any lead to which part may have gone wrong, why the discrepancy between two outcomes?

UPDATES

enter image description here

3 Answers

it might not work for everyone else but running tsc index.ts --watch worked for me. You can try this out.

Documentation says

When input files are specified on the command line, tsconfig.json files are ignored.

That's why when you run tsc app.ts --watch, your tsconfig.json file isn't being applied. You're providing app.ts.

Related