Investigating long TypeScript compile times

I’m investigating why the compilation time for my Angular 2.0 TypeScript project went from around 4 seconds to around 15 seconds in a relatively short time.

I came across the very useful, but seemingly undocumented --diagnostics switch.

For example, here’s what I get when running tsc --noEmit --diagnostics on my project now:

Files:             231
Lines:           50872
Nodes:          170067
Identifiers:     65994
Symbols:       7712123
Types:          407677
Memory used:   600554K
I/O read:        0.43s
I/O write:       0.00s
Parse time:      1.13s
Bind time:       0.34s
Check time:     10.17s
Emit time:       0.00s
Total time:     11.64s

Here’s what I get when I run the same command on an earlier version of the project.

Files:             197
Lines:           30882
Nodes:          124208
Identifiers:     46201
Symbols:       5856945
Types:           10989
Memory used:    80412K
I/O read:        0.03s
I/O write:       0.00s
Parse time:      0.60s
Bind time:       0.27s
Check time:      0.93s
Emit time:       0.00s
Total time:      1.79s

The number of Types has gone way up, and so has the Check time.

Is it possible to get more detailed/verbose output from --diagnostics?

NodeJS v4.4.3, TypeScript v1.8.10. This is my tsconfig.json

  "compilerOptions": {
    "target": "es5",
    "module": "system",
    "moduleResolution": "node",

    "noImplicitAny": false,
    "noEmitOnError": false,

    "experimentalDecorators": true,

    "emitDecoratorMetadata": true,
    "removeComments": false
  "exclude": [

Leave a Reply

5 Comment threads
0 Thread replies
Most reacted comment
Hottest comment thread
1 Comment authors
Jason Recent comment authors
newest oldest most voted
Notify of

Seems I have found the culprit in my case. I did it the hard way; my process: Find the commit that made the compilation slow. Go through the history commit-by-commit and check the compile times. Comment out the changed code until the offending lines are found. Before the offending commit, I consistently got compile times of around 2-4 seconds, after the commit – 13-17 seconds. In my case, I have a class, with a accessTokenGetter field, which was initialized in the constructor: export class JwtConfig { //... accessTokenGetter: () => Observable<string>; //... constructor(private config?: IJwtConfig) { // ... this.accessTokenGetter =… Read more »


I could speed up the compile process from 15 sec. to 6-7 sec. by changing this single line of code: // slow: // ... .flatMap((receivedObj: MyType) => { let nextObservable: Observable<MySecondType> = this.dependingPut(receivedObj); return nextObservable || new Observable((observer) => {; }); }); // fast: .flatMap((receivedObj: MyType) => { let nextObservable: Observable<MySecondType> = this.dependingPut(receivedObj); return nextObservable || new Observable<MySecondType>((observer) => { // <--- use the generics!; }); }); From the Typescript handbook ( function identity<T>(arg: T): T { return arg; } // ... let output = identity("myString"); // type of output will be 'string' “Notice that we didn’t have… Read more »


For me, slowdowns were due to imports like import "./file.ts";. Removing the .ts extension makes things 90% faster: import "./file";


Compiler is known to be slow, you can use compiler in watch mode tsc -w or switch to webpack and ts-loader which expose transpileOnly option (no time consuming checks).


In my case compile time was around 15-30 seconds. After tsc --noEmit --diagnostics command I’ve noticed that I’m building 2k files. Solution was to exclude all files from node_modules folder:

  "compilerOptions": {...},
   "exclude": [

It is a good idea to exclude typings folder too.