brandonroberts / vladivostok-sample

1 stars 0 forks source link

Coping with compiler errors due to use of TS 2.0 (1.9x) features #17

Open wardbell opened 8 years ago

wardbell commented 8 years ago

We're stuck in some places because Victor uses features that are only available in TS 2.0 (actually 1.9x) and most editors (VS Code) won't know about those features.

For example, in router.d.ts some of the router properties are readonly:

    readonly routerState: RouterState;
    readonly urlTree: UrlTree;
    readonly events: Observable<Event>;

That TS service throws up on that. Which makes Router.routerState disappear. Which makes this line in hero-list.component.ts fail to compile

  ngOnInit(){
    this.sub = this.router
      .routerState  // <--- BOOM!
      .queryParams
      .subscribe(params => {
        this.selectedId =+ params['id'];
        this.service.getHeroes()
          .then(heroes => this.heroes = heroes);
      });
  }

I can get VS Code to acknowledge by creating a _workplace setting override_ that knows about the TS 2.0 (actually 1.9x) version.

// Place your settings in this file to overwrite default and user settings.
{   
  "typescript.tsdk": "C:/github/vlad-brandon/node_modules/typescript/lib"
}