Typescript definition of "Promise" not found


#1

Recently I’ve updated to ionic rc0. since then I see there is no typings folder or typings.json . The upgrade phase at
link here step 26 specifies that typings folder and json should be removed , after I removed it in webstorm all Promise types are changed to red indicating that the type is not defined , sorry to tell that I see no documentation regarding this .

If you can please answer this question regarding promise not found .
stackoverflow


#2

Hav you typed your Promise<T>.
And sometimes, with some libs, you have to change the Promise (ex. firebase.Promise<void>)


#3

import { Injectable } from ‘@angular/core’;
import { Storage } from ‘@ionic/storage’;
import {ILocalStorageService} from “./local-storage.interface”;

@Injectable()
export class LocalStorageService implements ILocalStorageService{
private local:Storage;

constructor() {
    this.local = new Storage();
}

get(key: string): Promise<any>{
    return this.local.get(key);
}
set(key: string, value: any): Promise<any>{
    return this.local.set(key,value);
}
remove(key: string): Promise<any>{
    return this.local.remove(key);
}
clear(): Promise<any>{
    return this.local.clear();
}

}

all the places where there is “Promise” I get it in red for the IDE can’t recognize this type , bare in mind I deleted (as instructed by ionic2 rc0 upgrade ) the typings folder and json .


#4

Your code works for me, but I’m on rc1. Maybe there is a difference, I don’t know, but try with rc1, there is no big change between rc0 and rc1 (unlike beta.11 and rc0).


#5

Do you have any typings folder in your project ? … I’ve moved to rc1 still same problem .


#6

No. Not any typings folder. That’s weird. What does your compiler show ?


#7

The compile process works , the problem is with intelisense and go to definition .


#8

Oh oay. I tought the problem that it was not compiling.
I won’t be able to help you in this case if it is a problem with your IDE.


#9

I have webstorm , but as I see it the project has no definition for “Promise” , how did your IDE identifies the “Promise” definition ? or if you click on “Promise” to check definition ( go to definition ) does it shows you the def ? you see the problem is that def needs to come from some source ( d.ts file or js ) and since ionic2 rc1 removed the typings folder I don’t understand how they want types like “Promise” to be defined .


#10

See if you can change which TypeScript Webstorm is using, and point it at some >=2.0.0 version.


#11

Same here, I manually changed webstorm to point to the local Typescript libs 2.0.3 and nothing changed.
If I add es6 promise typing the compiler complaints about duplicated definitions.

UPDATE: Changing JavaScript to ECMAScript 6 fixes the problem.

Regards


#12

How do you do that ?


#13

Found it , settings -> Languages & Frameworks -> JavaScript -> set language version .