Skip to content

Super slow compilation in rare cases when mixing explicit typing, generics and type-inference #7460

@choeller

Description

@choeller

TypeScript Version:

1.8.7

Code

Having three classes like this:

import {Subject} from 'rxjs/Rx';
import {Task} from '../../models/task'
import {TaskStore} from "../task-store/task-store";

export class TaskService {
  //foo = "bar";   // -> commenting in solves slow compilation
  tasks: Subject<Task[]>;
}
import {Task} from "../../models/task";
import {BehaviorSubject} from "rxjs/Rx";

export class TaskStore {
  tasks =  new BehaviorSubject([]);
  //tasks = new BehaviorSubject<Task[]>([]); // -> change above line withis this one solves slow compilation
  //_tasks =  new BehaviorSubject([]);  // -> change above line withis this one solves slow compilation
}
import {bootstrap} from 'angular2/platform/browser';
import {TaskStore} from "./app/services/task-store/task-store";
import {TaskService} from './app/services/task-service/task-service';

class TestClass {
}

bootstrap(TestClass, [
    TaskService,
    TaskStore,
]);

leads to super slow compilation. Commenting in any of the lines above makes the compilation about 6 times faster.

See this repositiory as a reference for the problem:

https://github.com/choeller/slow-ts-compiler-demo/

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions