我的項目目前正在使用Angular RC4的Ionic2 Beta 11。問題是,我需要鏈條如下(我用的插件返回一個承諾):Typescript錯誤:找不到名字'Promise'
this.dataService.loginWithFacebookNative()
.then(
result => {
console.log(result)
return result;
},
error => {
console.log(error);
if (error == 'cordova_not_available') return this.dataService.loginWithFacebook();
return Promise.reject(error.message || error); // Here is the ts error
})
.then(value => {
console.log(value);
// Logic if login was a success
})
.catch(error => {
console.log(error);
if (error) {
this.error = error;
}
})
雖然應用程序本身是否按預期運行,打字稿將返回一個錯誤,指出
[ts] Cannot find name 'Promise'
我不確定從哪裏得到承諾。
有幾種類型可以提供Promise,es6-promise和core-js是我們想到的兩種。我知道Angular quick-start/tutorials使用core-js。我不確定Ionic框架使用什麼,但您可以從其中一個開始。 –