【问题标题】:IONIC2 Apollo Graphql Eror: Cannot find name 'AsyncIterator'IONIC2 Apollo Graphql 错误:找不到名称“AsyncIterator”
【发布时间】:2017-09-13 21:43:23
【问题描述】:

我开始使用 graphql 服务开发 ionic 应用程序,但我在节点模块中遇到了一些问题,我该如何解决?

[14:32:44]  typescript: D:/ionic/node_modules/@types/graphql/subscription/subscribe.d.ts, line: 17 
            Cannot find name 'AsyncIterator'.

      L16:      subscribeFieldResolver?: GraphQLFieldResolver<any, any>
      L17:  ): AsyncIterator<ExecutionResult>;

[14:32:44]  typescript: D:/ionic/node_modules/@types/graphql/subscription/subscribe.d.ts, line: 29 
            Cannot find name 'AsyncIterable'.

      L28:      fieldResolver?: GraphQLFieldResolver<any, any>
      L29:  ): AsyncIterable<any>;

这是我的 package.json

 {
      "name": "Test",
      "author": "test,
      "homepage": "http://test.com",
      "private": true,
      "scripts": {
        "clean": "ionic-app-scripts clean",
        "build": "ionic-app-scripts build",
        "ionic:build": "ionic-app-scripts build",
        "ionic:serve": "ionic-app-scripts serve"
      },
      "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": "^1.1.9",
        "angular2-jwt": "^0.1.28",
        "apollo-angular": "^0.13.0",
        "apollo-client": "^1.9.1",
        "graphql-tag": "^2.4.2",
        "ionic-angular": "^2.1.0",
        "ionic-native": "2.5.1",
        "ionicons": "3.0.0",
        "rxjs": "5.2.0",
        "sw-toolbox": "3.6.0",
        "zone.js": "0.7.7"
      },
      "devDependencies": {
        "@ionic/app-scripts": "^2.1.4",
        "typescript": "^2.3.4"
      },
      "cordovaPlugins": [
        "ionic-plugin-keyboard",
        "cordova-plugin-whitelist",
        "cordova-plugin-console",
        "cordova-plugin-statusbar",
        "cordova-plugin-device",
        "cordova-plugin-splashscreen",
        "cordova-plugin-camera",
        "cordova-plugin-app-version"
      ],
      "cordovaPlatforms": [],
      "description": "TEST"
    }

【问题讨论】:

标签: ionic2 graphql apollo-client


【解决方案1】:

从错误消息看来,您安装了graphql-js 的类型声明。 npm 链接是here

类型声明链接here

package.json 中似乎既没有类型声明也没有库。

如果这是您打算使用的库,您需要使用--save 选项安装,如下所示:

npm install --save graphql

并带有save-dev 选项的类型以添加​​到开发依赖项。

npm install --save-dev @types/graphql

【讨论】:

  • 感谢印度兄弟的精彩回答!节省了我 3 天的时间
【解决方案2】:

"esnext.asynciterable" 库添加到文件 tsconfig.json

"compilerOptions": {
  "lib": [
     . . .
     "esnext.asynciterable"
     . . .
   ],
. . .

【讨论】:

    猜你喜欢
    • 2019-01-11
    • 2021-07-28
    • 2017-04-08
    • 2019-02-13
    • 2020-04-18
    • 2018-06-28
    • 2021-03-18
    • 2020-07-08
    • 2016-01-24
    相关资源
    最近更新 更多