2017-08-12 5 views
0

Apollo ClientをIonic Angular 2アプリに追加しようとしています。私は公式の文書に従った。 Apollo Clientで角型2のTypescriptが失敗する

は、私はアポロClientインスタンス

// src/apollo/client.ts 
import { ApolloClient, createNetworkInterface } from 'apollo-client' 

export const Client = new ApolloClient({ 
    networkInterface: createNetworkInterface({ 
    uri: 'http://localhost:4000/graphiql-tool', 
    // opts: { 
    // credentials: 'same-origin', 
    // }, 
    }) 
}) 

//app.module.ts 
import { ApolloModule } from 'apollo-angular' 
import { Client } from '../apollo/client' 

@NgModule({ 
    imports: [ 
    BrowserModule, 
    IonicModule.forRoot(MyApp), 
    ApolloModule.forRoot(() => Client) 
    ] 
    // ... 
}) 
export class AppModule {} 

を追加

npm install apollo-client apollo-angular graphql-tag --save 

パッケージをインストールし、私は、アプリケーションを実行しようとしたが、活字体のコンパイルが

> ionic-app-scripts serve 

[08:25:11] ionic-app-scripts 1.3.7 
[08:25:11] watch started ... 
[08:25:11] build dev started ... 
[08:25:11] clean started ... 
[08:25:11] clean finished in 23 ms 
[08:25:11] copy started ... 
[08:25:11] transpile started ... 
[08:25:15] typescript: node_modules/apollo-client/core/types.d.ts, line: 17 
      ',' expected. 

     L16: }; 
     L17: export declare type ApolloExecutionResult<T = { 
     L18:  [key: string]: any; 

[08:25:15] typescript: node_modules/apollo-client/core/types.d.ts, line: 17 
      '>' expected. 

     L16: }; 
     L17: export declare type ApolloExecutionResult<T = { 
     L18:  [key: string]: any; 

[08:25:15] typescript: node_modules/apollo-client/core/types.d.ts, line: 19 
      ';' expected. 

     L18:  [key: string]: any; 
     L19: }> = { 
     L20:  data?: T; 

[08:25:15] typescript: node_modules/apollo-client/core/types.d.ts, line: 19 
      Expression expected. 

     L18:  [key: string]: any; 
     L19: }> = { 
     L20:  data?: T; 

[08:25:15] typescript: node_modules/apollo-client/core/types.d.ts, line: 20 
      Expression expected. 

     L19: }> = { 
     L20:  data?: T; 
     L21: }; 

がさらにあります失敗しますこのようなエラー。私は答えを見つけようとしましたが、TypescriptのエラーとApollo Clientに関連するすべてが見つかりましたが、私はそれについて良い結果を得ていません。タイプの定義を活字にする

依存関係

"dependencies": { 
    "@angular/common": "4.1.0", 
    "@angular/compiler": "4.1.0", 
    "@angular/compiler-cli": "4.1.0", 
    "@angular/core": "4.1.0", 
    "@angular/forms": "4.1.0", 
    "@angular/http": "4.1.0", 
    "@angular/platform-browser": "4.1.0", 
    "@angular/platform-browser-dynamic": "4.1.0", 
    "@ionic-native/core": "3.7.0", 
    "@ionic-native/splash-screen": "3.7.0", 
    "@ionic-native/status-bar": "3.7.0", 
    "@ionic/storage": "2.0.1", 
    "apollo-angular": "^0.13.0", 
    "apollo-client": "^1.9.1", 
    "graphql-tag": "^2.4.2", 
    "ionic-angular": "3.2.1", 
    "ionicons": "3.0.0", 
    "rxjs": "5.1.1", 
    "sw-toolbox": "3.6.0", 
    "zone.js": "0.8.10" 
    }, 
    "devDependencies": { 
    "@ionic/app-scripts": "1.3.7", 
    "@ionic/cli-plugin-ionic-angular": "1.1.2", 
    "ionic": "3.6.0", 
    "typescript": "2.2.1" 
    }, 

マイtypescriptファイル

{ 
    "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" 
    ], 
    "compileOnSave": false, 
    "atom": { 
    "rewriteTsconfig": false 
    } 
} 

答えて

0

すべてのポイントが間違っています。おそらくいくつかのパッケージのアップデートで消えてしまうものもあります。

は今のところ唯一欠けている一つは、それがこのhttps://github.com/apollographql/graphql-subscriptions/issues/83

によって閉鎖されている

[午前10時38分46秒]

typescript: node_modules/@types/graphql/subscription/subscribe.d.ts, line: 17 
      Cannot find name 'AsyncIterator'. 

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

[10:38:46] typescript: node_modules/@types/graphql/subscription/subscribe.d.ts, line: 29 
      Cannot find name 'AsyncIterable'. 

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

です

関連する問題