Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

{
  "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

like image 350
Isaac Avatar asked Sep 19 '25 22:09

Isaac


1 Answers

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.

like image 109
brainzerg Avatar answered Sep 21 '25 12:09

brainzerg