Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make gulp-typescript show errors?

I am developing an Angular2/Typescript app in VisualStudio and wanted to set up my own ts compiler, but whenever I run it and it finds errors I don't get details about them just this:

[16:22:23] Starting 'compile:typescript'...
[16:22:26] TypeScript: 1 semantic error
[16:22:26] TypeScript: emit failed
[16:22:26] Finished 'compile:typescript' after 3.14 s

My gulpfile.js is kind of big, but the relevant part is here:

var gulp = require('gulp');
var del = require('del');
var ts = require("gulp-typescript");
var gutil = require("gulp-util");
var watchifiy = require('watchify');
var sourcemaps = require('gulp-sourcemaps');

// --------------------------  COMPILE TS ---------------------------
gulp.task('compile:typescript', function () {
    var tsResult = gulp.src('./Scripts/**/*.ts', { base: './Scripts' })
        .pipe(sourcemaps.init())
        .pipe(ts(
                ts.createProject('Scripts/tsconfig.json'),
                undefined,
                ts.reporter.fullReporter()));

    return tsResult.js
        .pipe(sourcemaps.write())
        .pipe(gulp.dest('./Scripts'));
})

tsconfig.json:

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false,
    "noEmitOnError": true
  },
  "exclude": [
    "node_modules",
    "typings/globals",
    "typings/index.d.ts"
  ]
}

Would be thankful for any ideas.

like image 664
Milan Gulyas Avatar asked Nov 27 '25 08:11

Milan Gulyas


1 Answers

Update

It looks like this is a known bug, found here.

Original

I would suggest using the gulp-debug package, it allows you to .pipe into your tasks and capture standard output.

Debug vinyl file streams to see what files are run through your gulp pipeline

gulpfile.js

var debug = require("gulp-debug");
gulp.task('compile:typescript', function () {
    var tsResult = gulp.src('./Scripts/**/*.ts', { base: './Scripts' })
        .pipe(sourcemaps.init())
        .pipe(debug()) // here...
        .pipe(ts(
                ts.createProject('Scripts/tsconfig.json'),
                undefined,
                ts.reporter.fullReporter()));

    return tsResult.js
        .pipe(sourcemaps.write())
        .pipe(gulp.dest('./Scripts'));
})

You'll need to add it to the list of devDependencies in your package.json so that npm will install it.

like image 103
David Pine Avatar answered Nov 29 '25 22:11

David Pine



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!