frankwallis / plugin-typescript

TypeScript loader for SystemJS
MIT License
248 stars 47 forks source link

Problems with typings in rxjs #125

Closed svi3c closed 8 years ago

svi3c commented 8 years ago

I have this entry in my jspm config:

{
  // ...
  "map": {
    // ...
    "rxjs": "npm:rxjs@5.0.0-beta.6",
    // ...
  },
  "packages": {
    // ...
    "rxjs": {
      "meta": {
        // "*.js": {"typings": true}, // FIXME: This somehow let the compilation process crash.
        // "add/operator/do.js": {"typings": true}, // FIXME: This somehow let the compilation process crash.
        "Observable.js": {"typings": true},
        "Subject.js": {"typings": true},
        "BehaviorSubject.js": {"typings": true}
      }
    },
    // ...
  }
  // ...
}

I'm importing rxjs/add/operators/do in one of my typescript files (src/dev/tools.dev.ts) via

import "rxjs/add/operator/do";
import {Middleware} from "@ngrx/store";

class DevTools {
  currentState: any;
  stateLogging: Middleware = state => state.do((val: any) => console.log("State changed", val));
  stateTracking: Middleware = state => state.do((val: any) => this.currentState = val);
}

export let dev = new DevTools();

When I uncomment one of the FIXME lines in the JSPM config above, the typescript compilation crashes with the following error:

err  Error on translate for src/app/todos/todo.ts at [...]
  Loading src/app/todos/todo.service.ts
  Loading src/app/todos.ts
  Loading src/dev/main.dev.ts
  TypeError: Cannot read property 'charCodeAt' of undefined
    at getRootLength (file:///home/sven/dev/projects/angular2-setup-poc/jspm_packages/npm/typescript@1.8.10/lib/typescript.js:1414:17)
    at isRootedDiskPath (file:///home/sven/dev/projects/angular2-setup-poc/jspm_packages/npm/typescript@1.8.10/lib/typescript.js:1482:16)
    at Object.toPath (file:///home/sven/dev/projects/angular2-setup-poc/jspm_packages/npm/typescript@1.8.10/lib/typescript.js:936:36)
    at Object.getSourceFile (file:///home/sven/dev/projects/angular2-setup-poc/jspm_packages/npm/typescript@1.8.10/lib/typescript.js:39912:39)
    at resolveExternalModuleNameWorker (file:///home/sven/dev/projects/angular2-setup-poc/jspm_packages/npm/typescript@1.8.10/lib/typescript.js:15771:53)
    at mergeModuleAugmentation (file:///home/sven/dev/projects/angular2-setup-poc/jspm_packages/npm/typescript@1.8.10/lib/typescript.js:15061:34)
    at initializeTypeChecker (file:///home/sven/dev/projects/angular2-setup-poc/jspm_packages/npm/typescript@1.8.10/lib/typescript.js:29258:25)
    at Object.createTypeChecker (file:///home/sven/dev/projects/angular2-setup-poc/jspm_packages/npm/typescript@1.8.10/lib/typescript.js:14907:9)
    at getDiagnosticsProducingTypeChecker (file:///home/sven/dev/projects/angular2-setup-poc/jspm_packages/npm/typescript@1.8.10/lib/typescript.js:39871:93)
    at Object.getGlobalDiagnostics (file:///home/sven/dev/projects/angular2-setup-poc/jspm_packages/npm/typescript@1.8.10/lib/typescript.js:40154:41)
    at TypeChecker.getAllDiagnostics (file:///home/sven/dev/projects/angular2-setup-poc/jspm_packages/github/frankwallis/plugin-typescript@4.0.9/type-checker.js:96:32)
    at TypeChecker.check (file:///home/sven/dev/projects/angular2-setup-poc/jspm_packages/github/frankwallis/plugin-typescript@4.0.9/type-checker.js:35:37)
    at file:///home/sven/dev/projects/angular2-setup-poc/jspm_packages/github/frankwallis/plugin-typescript@4.0.9/plugin.js:38:45

The funny thing about this is that src/app/todos/todo.ts has nothing to do with the import. Here is it's content:

export interface Todo {
  text: string;
  done?: boolean;
}

Any ideas or suggestions how to track this error down?

frankwallis commented 8 years ago

Thank you for raising this, it should be fixed in 4.0.10

svi3c commented 8 years ago

Great, works for me! :)