简体   繁体   English

如何修复ionic 3中的Typescript错误? 索引.d.ts

[英]how to fix Typescript error in ionic 3? index.d.ts

This is the error I'm having right now这是我现在遇到的错误

this is my package.json这是我的 package.json

{ "name": "Ambusis", "version": "0.0.1", "author": "Ionic Framework", "homepage": " http://ionicframework.com/ ", "private": true, "scripts": { "clean": "ionic-app-scripts clean", "build": "ionic-app-scripts build", "lint": "ionic-app-scripts lint", "ionic:build": "ionic-app-scripts build", "ionic:serve": "ionic-app-scripts serve" }, { "name": "Ambusis", "version": "0.0.1", "author": "Ionic Framework", "homepage": " http://ionicframework.com/ ", "private": true, "脚本": { "clean": "ionic-app-scripts clean", "build": "ionic-app-scripts build", "lint": "ionic-app-scripts lint", "ionic:build": " ionic-app-scripts build", "ionic:serve": "ionic-app-scripts serve" },

  "dependencies": {
    "@angular/animations": "5.2.9",
    "@angular/common": "5.2.9",
    "@angular/compiler": "5.2.9",
    "@angular/compiler-cli": "5.2.9",
    "@angular/core": "5.2.9",
    "@angular/fire": "^5.3.0",
    "@angular/forms": "5.2.9",
    "@angular/http": "5.2.9",
    "@angular/platform-browser": "5.2.9",
    "@angular/platform-browser-dynamic": "5.2.9",
    "@angular/router": "^3.4.10",
    "@ionic-native/browser-tab": "^4.7.0",
    "@ionic-native/core": "4.6.0",
    "@ionic-native/diagnostic": "^4.7.0",
    "@ionic-native/firebase": "^5.19.1",
    "@ionic-native/geolocation": "^4.7.0",
    "@ionic-native/in-app-browser": "^4.7.0",
    "@ionic-native/location-accuracy": "^4.7.0",
    "@ionic-native/network": "^4.7.0",
    "@ionic-native/social-sharing": "^4.7.0",
    "@ionic-native/splash-screen": "4.6.0",
    "@ionic-native/status-bar": "4.3.1",
    "@ionic/storage": "2.1.3",
    "cordova-android": "8.1.0",
    "cordova-plugin-browsertab": "^0.2.0",
    "cordova-plugin-compat": "^1.2.0",
    "cordova-plugin-device": "^2.0.1",
    "cordova-plugin-firebase": "^2.0.5",
    "cordova-plugin-geolocation": "^4.0.1",
    "cordova-plugin-inappbrowser": "^3.2.0",
    "cordova-plugin-ionic-keyboard": "^2.0.5",
    "cordova-plugin-ionic-webview": "^4.1.2",
    "cordova-plugin-network-information": "^2.0.1",
    "cordova-plugin-request-location-accuracy": "^2.2.2",
    "cordova-plugin-splashscreen": "^5.0.2",
    "cordova-plugin-whitelist": "^1.3.3",
    "cordova-plugin-x-socialsharing": "^5.4.0",
    "cordova.plugins.diagnostic": "^4.0.5",
    "es6-promise-plugin": "^4.2.2",
    "firebase": "^7.6.2",
    "ionic-angular": "^3.9.9",
    "ionic2-rating": "^1.2.2",
    "ionic2-super-tabs": "^4.2.2",
    "ionicons": "3.0.0",
    "pkg.json": "^2.0.7",
    "rxjs": "5.5.8",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.20"
  },
  "devDependencies": {
    "@ionic/app-scripts": "^3.2.4",
    "@ionic/lab": "2.0.18",
    "typescript": "~3.1.3"
  },
  "description": "An Ionic project",
  "cordova": {
    "plugins": {
      "cordova-plugin-network-information": {},
      "cordova-plugin-geolocation": {},
      "cordova-plugin-whitelist": {},
      "cordova-plugin-device": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-ionic-webview": {
        "ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
      },
      "cordova-plugin-ionic-keyboard": {},
      "cordova.plugins.diagnostic": {
        "ANDROID_SUPPORT_VERSION": "28.+"
      },
      "cordova-plugin-request-location-accuracy": {
        "PLAY_SERVICES_LOCATION_VERSION": "16.+"
      },
      "cordova-plugin-x-socialsharing": {
        "ANDROID_SUPPORT_V4_VERSION": "24.1.1+"
      },
      "cordova-plugin-browsertab": {},
      "cordova-plugin-inappbrowser": {},
      "cordova-plugin-firebase": {}
    },
    "platforms": [
      "android"
    ]
  }
}

this is the code it is referring to这是它所指的代码

export type CustomEventName<T> = T extends EventNameString ? never : T;

this is my tsconfig.json这是我的 tsconfig.json

{
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [
      "dom",
      "es2015"
    ],
    "module": "es2015",
    "moduleResolution": "node",
    "sourceMap": true,
    "target": "es5"
  },
  "include": [
    "src/**/*.ts"
  ],
  "exclude": [
    "node_modules",
    "src/**/*.spec.ts",
    "src/**/__tests__/*.ts"
  ],
  "compileOnSave": false,
  "atom": {
    "rewriteTsconfig": false
  }
}

PS if I save a file, It will be fixed PS如果我保存文件,它将被修复

thanks in advance guys!提前谢谢你们!

EDIT:编辑:

after following sir john's advice, only one error is now left.按照约翰爵士的建议,现在只剩下一个错误了。

Okay add skipLibCheck so that it will skip type checking of all declaration files (*.d.ts) on compilation.好的,添加skipLibCheck,以便在编译时跳过所有声明文件(*.d.ts)的类型检查。

should be like this应该是这样的

{
  "compilerOptions": {
    "skipLibCheck": true,
    "allowSyntheticDefaultImports": true,
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [
      "dom",
      "es2015"
    ],
    "module": "es2015",
    "moduleResolution": "node",
    "sourceMap": true,
    "target": "es5"
  },
  "include": [
    "src/**/*.ts"
  ],
  "exclude": [
    "node_modules",
    "src/**/*.spec.ts",
    "src/**/__tests__/*.ts"
  ],
  "compileOnSave": false,
  "atom": {
    "rewriteTsconfig": false
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何生成Android Typescript.d.ts文件 - How to generate Android Typescript.d.ts files 如何在ionic2其他ts文件中导入config ts文件 - how to import the config ts file in ionic2 other ts file 如何解决此错误:生成EACCES-离子Cordova构建iOS - How to fix this Error: spawn EACCES - ionic cordova build ios 如何修复Ionic中的&#39;没有导出的成员&#39;VeiwChild&#39;错误 - How to fix 'has no exported member 'VeiwChild'' error in Ionic 如何修复错误类型'String'不是'index'的'int'类型的子类型? - How to fix the error type 'String' is not a subtype of type 'int' of 'index'? 建立时出现离子给打字稿错误 - Ionic Giving Typescript error while Building 如何修复错误 json.JSONException:索引 1 超出范围 [0..1) - How to fix Error json.JSONException: Index 1 out of range [0..1) 我如何修复离子mac android模拟器错误中的“模拟器:无法同步vcpu reg”错误 - How do i fix “emulator: Failed to sync vcpu reg” error in ionic mac android emulator error 运行 ionic cordova build android 时如何修复 AAPT 错误前台活动未找到? - how to fix AAPT error foreground activity not found when running ionic cordova build android? 如何使用Ionic 2在打字稿中获取实际日期 - How to get actual date in typescript with Ionic 2
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM