TypeScript Version: 2.0.10
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"noImplicitAny": true,
"sourceMap": true,
"noEmitOnError": true,
"strictNullChecks": true,
"noUnusedParameters": true
},
"exclude": [
"node_modules"
]
}
Expected behavior:
Should compile into script.js
Actual behavior:
script.ts(51,7): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
script.ts(55,7): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
Works when you use the command tsc script.ts --t es5
where is your tsconfig.json relative to script.ts?
both files are in the root directory
You are getting the error because you are invoking the compiler on a specific file. It is ignoring your tsconfig. If you use tsc -p tsconfig.json or just tsc it will work.
Most helpful comment
You are getting the error because you are invoking the compiler on a specific file. It is ignoring your tsconfig. If you use
tsc -p tsconfig.jsonor justtscit will work.