Gulp TypeScript build error TypeError Cannot read property 'length' of undefined at Object.emit [as writeFile] gulp-typescript\release\compiler.js

October 03, 2019

At work we use a TS “native” approach with tsconfig.json settings and running tsc compiler approach + gulp-typescript with some tuned building pipelines and some logic. We switched on incremental builds and we liked it, but it seems that while this worked side by side with TS +- 3.5.3, having set

incremental: true

in tsconfig.json and having TS 3.6.3 will result in error like this :

TypeError: Cannot read property 'length' of undefined
    at Object.emit [as writeFile] (/path/here/node_modules/gulp-typescript/release/compiler.js:81:33)

so either you will turn off the setting in tsconfig.json file or tweak it in gulpfile like here : https://github.com/ivogabe/gulp-typescript

var tsProject = ts.createProject('tsconfig.json', { noImplicitAny: true, incremental: false });

Credits go to these guys here, thx : http://quabr.com/58031957/typescript-throws-a-cannot-read-property-length-of-undefined-when-run-throug

Hope this helps.


Profile picture

Written by Dušan Roštár - the "mr edge case" guy
my twitter : rostacik, my linkedin : rostar
Reach me at dusan at thisdomain.net