I'm coming up with an this error message while transcompiling TS to JS using gulp-typescript. I'm attempting to use an ES5 feature for getters/setters.
error TS1056: Accessors are only available when targeting ECMAScript 5 and higher
How do I get the transcompiler to target es5?
I googled around for solutions which suggest that you set target = es5
and pass it through to the typescript. I have done the following using a 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()));
});
logged output