0

I have a question regarding the differences of the Atom typescript/angular compiler vs the one of Ionic.

I have a piece of code that connects to a web service:

import {Component, OnInit} from '@angular/core';
import {NavController} from 'ionic-angular';
import { HTTP_PROVIDERS, Http } from '@angular/http';    
import { Module } from './module';

... some more not relevant code ...

  getConfiguredModules(){
    return new Promise(resolve => {
      this._http.get('http://localhost:8080/rest/modules/configuredModules')
        .map(res => <Array<Module>>(res.json()))
        .subscribe(modules => {
          this.configuredModules = modules;
          resolve(this.configuredModules);
          this.configuredModulesLoaded = true;
        });
    });
  }

Atom compiler doesn't complain about this piece of code, but when I start Ionic 2 with 'ionic serve', I see the following error:

TypeScript error: pathToProject/modules.ts(26,14): Error TS2339: Property 'map' does not exist on type 'Observable'.

When I check the Angular version of Ionic with

npm info generator-angular-fullstack

I see:

beta: '4.0.0-beta.4'

My question is: How can I ensure Atom uses the same angular/typescript version as I see in npm?

Dan Lowe
  • 51,713
  • 20
  • 123
  • 112
Rens Groenveld
  • 960
  • 11
  • 28
  • You need to import the `map` operator http://stackoverflow.com/questions/34515173/angular-2-http-get-with-typescript-error-http-get-map-is-not-a-function-in/34515276#34515276 – Günter Zöchbauer Jan 19 '17 at 06:39
  • 1
    Thanks for the comment. In the end I solved it with using a newer version of Atom and Angular, which were both in sync. Next time it happens I will check it out though :) – Rens Groenveld Jan 20 '17 at 09:05

0 Answers0