Unresolved variable or type async await

My Project configuration is Node 6.10.0, Ionic 2.2.1, Typescript 2.0.6 and Angular 2.1.1. I have some other Ionic-native plugins v4.1.0-4.3.0. I am getting unresolved variable or type async await in my project for the current configuration. Do I need to update my Ionic/ Angular to code async/await ? will updating Ionic/ Angular affect installation of Ionic-native plugins ?

I have another project with this configuration:

 "dependencies": {
    "@angular/common": "5.0.3",
    "@angular/compiler": "5.0.3",
    "@angular/compiler-cli": "5.0.3",
    "@angular/core": "5.0.3",
    "@angular/forms": "5.0.3",
    "@angular/http": "5.0.3",
    "@angular/platform-browser": "5.0.3",
    "@angular/platform-browser-dynamic": "5.0.3",
    "@ionic-native/core": "4.4.0",
    "@ionic-native/splash-screen": "4.4.0",
    "@ionic-native/status-bar": "4.4.0",
    "@ionic/storage": "2.1.3",
    "cordova-android": "^7.0.0",
    "cordova-plugin-device": "^2.0.1",
    "cordova-plugin-ionic-keyboard": "^2.0.5",
    "cordova-plugin-ionic-webview": "^1.1.16",
    "cordova-plugin-splashscreen": "^5.0.2",
    "cordova-plugin-whitelist": "^1.3.3",
    "ionic-angular": "3.9.2",
    "ionicons": "3.0.0",
    "rxjs": "5.5.2",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.18"
  },
  "devDependencies": {
    "@ionic/app-scripts": "3.1.8",
    "typescript": "2.4.2"
  },

Still getting the same error mark while coding async/await. What am I missing ? Here is my async/await code:

async getImei() {
  const { hasPermission } = await this.androidPermissions.checkPermission(
    this.androidPermissions.PERMISSION.READ_PHONE_STATE
  );

  if (!hasPermission) {
    const result = await this.androidPermissions.requestPermission(
      this.androidPermissions.PERMISSION.READ_PHONE_STATE
    );

    if (!result.hasPermission) {
      throw new Error('Permissions required');
    }

    return;
  }

  return this.uid.IMEI;
}
1 Like

I didn’t look at your code, because your description of your setup has a lot of red flags. Do you see how the versions you report are different from what’s in package.json? You could have all kinds of weird errors. Also, I don’t even know how Typescript 2.0x handles async/await.

Install the current Node LTS, and the most recent version of Ionic 3. Then read the Ionic changelog to determine which version of Typescript to install. Make sure your package.json is consistent with the changelog.

Ok, the package.json I pasted here is from another project with this configuration ,which i forgot to mention,

Ionic Framework Version: 3.9.2
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 3.1.8
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Windows 8.1
Node Version: v6.10.0

and Typescript 2.4.2