Closed
Description
On the command line, my project compiles fine using:
tsc -p tsconfig.json
When using gulp-typescript 3.0 with TS 2.0, I get tons of comilation errors.
Apparently, TS does not know built-in objects such as Object
, Function
, RegExp
, Promise
, etc.
This should be covered by lib
in my tsconfig options (and works on command line):
{
"compilerOptions": {
"target": "es6",
"module": "amd",
"outFile": "main.js",
"allowJs": true,
"lib": [ "dom", "es2017" ],
"skipDefaultLibCheck": true,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"strictNullChecks": true,
"noImplicitThis": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"noFallthroughCasesInSwitch": true
}
}
For reference, this is how I invoke gulp-ts:
const ts = require('gulp-typescript');
const tsProject = ts.createProject('App/tsconfig.json', { noResolve: true });
gulp.task('javascript', function () {
const babel = require('gulp-babel');
const gulpif = require('gulp-if');
const sourcemaps = require('gulp-sourcemaps');
return gulp.src(['**/*.ts', 'config.js'], { cwd: 'App' })
.pipe(gulpif(options.sourcemaps, sourcemaps.init()))
.pipe(tsProject())
.js
.pipe(babel({ presets: ['es2015-loose'], compact: true }))
.pipe(gulpif(options.minify, uglify()))
.pipe(gulpif(options.sourcemaps, sourcemaps.write()))
.pipe(gulp.dest('wwwroot/dist'));
});