I am encountering an error message while transcompiling TypeScript to JavaScript using gulp-typescript. The issue arises when I try to utilize getters/setters which are only available in ECMAScript 5 and higher.
error TS1056: Accessors are only available when targeting ECMAScript 5 and higher
How can I configure the transcompiler to target es5?
I have searched for solutions online and found recommendations to set target = es5
in the tsconfig.json file used by TypeScript compiler. Here is how I updated my tsconfig.json:
tsconfig.js
{
"compilerOptions": {
"target": "es5"
},
"files": []
}
Gulp Task
import gulp from 'gulp';
import gulpif from 'gulp-if';
import livereload from 'gulp-livereload';
import typescript from 'gulp-typescript';
import args from './lib/args';
const tsProject = typescript.createProject('tsconfig.json');
console.log(tsProject);
gulp.task('scripts-typescript', () => {
return gulp.src('app/scripts/**/*.ts')
.pipe(typescript(tsProject()))
.pipe(gulp.dest(`dist/${args.vendor}/scripts`))
.pipe(gulpif(args.watch, livereload()));
});
Output after logging