Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
choeller opened this issue Mar 10, 2016 · 4 comments
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@choeller
Copy link

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/

@sandersn
Copy link
Member

This looks like a dupe of #7082 or the other problems with compiling RxJs. @vladima can you take a look?

@sandersn sandersn added the Duplicate An existing issue was already created label Mar 10, 2016
@sandersn
Copy link
Member

As a quick overview of the problem, caching is broken for class this types and RxJs is a commonly used project that relies on caching common base types to be able to compile fast enough.

@mhegazy mhegazy closed this as completed Mar 10, 2016
@vladima
Copy link
Contributor

vladima commented Mar 10, 2016

I would keep this open, fix for this types does not make this issue completely go away - compilation time is dropped from 8-9 to ~6 seconds but still it is kind of slow. Crux of the problem - rxjs-5.0.0.beta2 exposes a number of types that look similar and quite complicated in structure and doing a full structural comparison of them takes a lot of time

Simplified repro: https://github.com/vladima/rxjs-issue - majority of time is spent doing subtype reduction.

@vladima vladima reopened this Mar 10, 2016
@vladima vladima added Bug A bug in TypeScript and removed Duplicate An existing issue was already created labels Mar 10, 2016
@mhegazy mhegazy added this to the TypeScript 2.0 milestone Mar 10, 2016
@vladima
Copy link
Contributor

vladima commented Jun 8, 2016

closing as fix to RxJS was already merged

@vladima vladima closed this as completed Jun 8, 2016
@vladima vladima added External Relates to another program, environment, or user action which we cannot control. Fixed A PR has been merged for this issue and removed External Relates to another program, environment, or user action which we cannot control. labels Jun 8, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

4 participants