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

Type count explosion creating an array of Rx Subject and Observable #7585

Closed
bobvawter opened this issue Mar 18, 2016 · 2 comments
Closed

Type count explosion creating an array of Rx Subject and Observable #7585

bobvawter opened this issue Mar 18, 2016 · 2 comments
Labels
Duplicate An existing issue was already created External Relates to another program, environment, or user action which we cannot control.

Comments

@bobvawter
Copy link

The following code produces a pathological (8+ seconds) type-checking behavior in the typescript 1.9.0-dev.20160318 compiler as well as mainline 1.8.9.

Using rxjs 5.0.0-beta.2 and typings for es6-shim:

import {Observable, BehaviorSubject} from "rxjs/Rx";

class HelperOne<R,S> {}
class HelperTwo<R,S> {}

class SlowZone<R,S> {
  private _helperOne /* TO FIX: Observable<HelperOne<R,S>> */ =
      new BehaviorSubject<HelperOne<R,S>>(null);

  constructor() {
    var helperTwo:Observable<HelperTwo<R,S>> = null;

    var x /* DOES NOT FIX : Observable<any>[] */ =
        [helperTwo, this._helperOne];
  }
}

Command used:

$ uname -a
Darwin dustbin.local 15.3.0 Darwin Kernel Version 15.3.0: Thu Dec 10 18:40:58 PST 2015; root:xnu-3248.30.4~1/RELEASE_X86_64 x86_64
$ node --version
v5.7.1
$ ./node_modules/.bin/tsc --version
Version 1.9.0-dev.20160318
$ ./node_modules/.bin/tsc --diagnostics --target es5 --emitDecoratorMetadata --experimentalDecorators --forceConsistentCasingInFileNames --removeComments --noFallthroughCasesInSwitch --noImplicitAny --noImplicitReturns --module system --moduleResolution node typings/browser.d.ts slow.ts
Files:              62
Lines:           19469
Nodes:           94193
Identifiers:     36579
Symbols:       2130530
Types:          360480
Memory used:   446169K
I/O read:        0.01s
I/O write:       0.02s
Parse time:      0.26s
Bind time:       0.16s
Check time:      8.30s
Emit time:       0.06s
Total time:      8.79s

If the _helperOne field is given an explicit type, the following timings are observed:

Files:              62
Lines:           19469
Nodes:           94201
Identifiers:     36583
Symbols:       1534285
Types:            8804
Memory used:    67693K
I/O read:        0.01s
I/O write:       0.00s
Parse time:      0.26s
Bind time:       0.16s
Check time:      0.65s
Emit time:       0.03s
Total time:      1.10s

I think this may be another root cause of slow compilation times for folks using Observable.combineLatest since it will accept as input an array of Observables and it appears that computing the type of the array may lead to excessive compile times.

@mhegazy
Copy link
Contributor

mhegazy commented Mar 18, 2016

Please see #7344 (comment)

@mhegazy mhegazy added External Relates to another program, environment, or user action which we cannot control. Duplicate An existing issue was already created labels Mar 18, 2016
@bobvawter
Copy link
Author

Building rxjs from master solves this in both tsc 1.8.9 and 1.9.0-dev.20160318. Thank you.

@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
Duplicate An existing issue was already created External Relates to another program, environment, or user action which we cannot control.
Projects
None yet
Development

No branches or pull requests

3 participants