当更新为离子原生v3时,离子服务会给出打字稿错误

时间:2017-03-22 08:13:22

标签: ionic2 ionic-native

运行ionic serve时,我从本机导入的每个项目中获取Typescript错误。这是在我更新为ionic-native v3之后。来自新的@ ionic-native的所有项目都不能被Typescript识别。我将打字稿更新到不同的v2版本,但无法使其工作。

我没有更改任何其他代码。它不仅与SplashScreen有关。所有我对我过去导入的对象的引用' ionic-native' (旧样式),现在通过@ ionic-native / {plugin-name}导入,给出这些Typescript错误。

有人可以帮忙吗?目前无法投放或构建我的应用

例如:

property hide does not exist on type typeof SplashScreen

我将导入更改为

import { LocalNotifications } from '@ionic-native/local-notifications';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';

我的离子信息:

 ordova CLI: 6.5.0
Ionic Framework Version: 2.2.0
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.1.4
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Windows 10
Node Version: v7.0.0
Xcode version: Not installed

我的离子插件ls

cordova-plugin-app-event 1.2.0 "Application Events"
cordova-plugin-app-version 0.1.9 "AppVersion"
cordova-plugin-camera 2.4.0 "Camera"
cordova-plugin-compat 1.1.0 "Compat"
cordova-plugin-console 1.0.6 "Console"
cordova-plugin-device 1.1.5 "Device"
cordova-plugin-fcm 2.1.1 "FCMPlugin"
cordova-plugin-nativestorage 2.2.1 "NativeStorage"
cordova-plugin-splashscreen 4.0.2 "Splashscreen"
cordova-plugin-statusbar 2.2.2 "StatusBar"
cordova-plugin-whitelist 1.3.2 "Whitelist"
cordova-plugin-x-socialsharing 5.1.6 "SocialSharing"
de.appplant.cordova.plugin.local-notification 0.8.4 "LocalNotification"
ionic-plugin-keyboard 2.2.1 "Keyboard"
phonegap-plugin-barcodescanner 6.0.5 "BarcodeScanner"

我的package.json

"dependencies": {
    "@angular/common": "2.4.8",
    "@angular/compiler": "2.4.8",
    "@angular/compiler-cli": "2.4.8",
    "@angular/core": "2.4.8",
    "@angular/forms": "2.4.8",
    "@angular/http": "2.4.8",
    "@angular/platform-browser": "2.4.8",
    "@angular/platform-browser-dynamic": "2.4.8",
    "@angular/platform-server": "2.4.8",
    "@ionic/storage": "2.0.0",
    "@ionic-native/core": "^3.1.0",
    "ionicons": "3.0.0",
    "ionic-angular": "2.2.0",
    "rxjs": "5.0.1",
    "zone.js": "0.7.2",
    "sw-toolbox": "3.5.1",
    "babel-core": "^6.24.0",
    "d": "^1.0.0",
    "ng2-translate": "^4.0.0",
    "@ionic-native/barcode-scanner": "^3.1.0",
    "@ionic-native/local-notifications": "^3.1.0",
    "@ionic-native/native-storage": "^3.1.0",
    "@ionic-native/social-sharing": "^3.1.0",
    "@ionic-native/splash-screen": "^3.1.0",
    "@ionic-native/status-bar": "^3.1.0"

  },
  "devDependencies": {
    "@ionic/app-scripts": "^1.1.4",
    "@ionic/cli-build-ionic-angular": "0.0.3",
    "@ionic/cli-plugin-cordova": "0.0.9",
    "typescript": "2.0.9"
  }

tsc -v

Version 2.2.1

1 个答案:

答案 0 :(得分:2)

根据更新的文档here,您需要在构造函数中注入Splashscreen。

constructor(private splashScreen: SplashScreen) { }
this.splashscreen.hide();

在以前的版本中,您将使用直接导入的Splashscreen来调用方法。