[Solved] Ionic RC0: error TS4053: Return type of public method from exported class has or is using name 'Entry' from external module


#1

I am upgrading my project to Ionic RC0 from Beta 11 by creating a new RC0 project and following the instructions in https://github.com/driftyco/ionic/blob/master/CHANGELOG.md

I have sorted out most of the issues, except for couple. One among them is following errors:

error TS4053: Return type of public method from exported class has or is using name 'Entry' from external module "/Users/saiy2k/projects/ionic/gr/node_modules/ionic-native/dist/es5/plugins/file" but cannot be named

error TS4053: Return type of public method from exported class has or is using name 'FileError' from external module "/Users/saiy2k/projects/ionic/gr/node_modules/ionic-native/dist/es5/plugins/file" but cannot be named.

error TS4053: Return type of public method from exported class has or is using name 'DirectoryEntry' from external module "/Users/saiy2k/projects/ionic/gr/node_modules/ionic-native/dist/es5/plugins/file" but cannot be named.

I Installed the File cordova plugin.

Any help is appreciated


How to set this.http.get Header
#2

I have the same problem with Observable:

  public fetchQuestions() {
    var url = Config.server+'/question';
    var response = this.http.get(url).map(res => res.json());
    return response;
  }

Produces the exact same error as you but with Observable…


#3

I have the same issue with Observable as well. First it tells me it is an unused import. Then I take it out and it gives me this error instead.


#4

You need to make an explicit import.

Mike was solving the same error in his video:

So in the case of Observable, add this line in the top:

import { Observable } from “rxjs/Observable”;


#5

I have the same issue for my 1 line … I add import { Observable } from “rxjs/Observable” in the top and this do not help !

src/providers/login.ts(46,4): error TS4053: Return type of public method from exported class has or is using name ‘Response’ from external module “D:/tmp/ionic2/rc0MyApp/node_modules/@angular/http/src/static_response” but cannot be named.

  1. login(user:User) {
    const data = JSON.stringify({u: user.username, p: user.password});
    return this.http.post(this.actions.login, data)
    }

#6

Importing Observable import { Observable } from "rxjs/Observable" in your provider and giving function type as Observable<your function type> ( for example Observable<number> ) will solve the problem.


#7

Just to be a bit more specific (I’m working my way through this as well):

I imported Observable (from rxjs/Observable) as well as Response (from @angular/http):

import { Http, Response } from '@angular/http';
import { Observable } from "rxjs/Observable";

Then I was able to “type” the login function return as “Observable” and get rid of the errors/warnings:

login(): Observable<Response> {
...
return this.http.post(url, JSON.stringify(params));
}

Hope that helps


#8

For my specific File import problem, this helped.

import {Entry} from 'ionic-native/dist/es5/plugins/file';
import {FileError} from 'ionic-native/dist/es5/plugins/file';
import {DirectoryEntry} from 'ionic-native/dist/es5/plugins/file';

from