Apollo-client: Typescript errors on fresh install

Created on 19 Jun 2017  路  6Comments  路  Source: apollographql/apollo-client

Intended outcome:

Installing should not produce any errors in typescript.

Actual outcome:

Typescript produced the following errors, immediately after installing apollo-client:

node_modules/@types/isomorphic-fetch/index.d.ts(8,30): error TS2304: Cannot find name 'fetch'.
node_modules/apollo-client/transport/afterware.d.ts(4,15): error TS2304: Cannot find name 'Response'.
node_modules/apollo-client/transport/afterware.d.ts(5,14): error TS2304: Cannot find name 'RequestInit'.
node_modules/apollo-client/transport/afterware.d.ts(11,16): error TS2304: Cannot find name 'Response'.
node_modules/apollo-client/transport/afterware.d.ts(12,14): error TS2304: Cannot find name 'RequestInit'.
node_modules/apollo-client/transport/batchedNetworkInterface.d.ts(8,14): error TS2304: Cannot find name 'RequestInit'.
node_modules/apollo-client/transport/batchedNetworkInterface.d.ts(11,16): error TS2304: Cannot find name 'Response'.
node_modules/apollo-client/transport/batchedNetworkInterface.d.ts(12,14): error TS2304: Cannot find name 'RequestInit'.
node_modules/apollo-client/transport/batchedNetworkInterface.d.ts(18,64): error TS2304: Cannot find name 'RequestInit'.
node_modules/apollo-client/transport/batchedNetworkInterface.d.ts(30,12): error TS2304: Cannot find name 'RequestInit'.
node_modules/apollo-client/transport/middleware.d.ts(5,14): error TS2304: Cannot find name 'RequestInit'.
node_modules/apollo-client/transport/middleware.d.ts(12,14): error TS2304: Cannot find name 'RequestInit'.
node_modules/apollo-client/transport/networkInterface.d.ts(31,12): error TS2304: Cannot find name 'RequestInit'.
node_modules/apollo-client/transport/networkInterface.d.ts(39,14): error TS2304: Cannot find name 'RequestInit'.
node_modules/apollo-client/transport/networkInterface.d.ts(42,15): error TS2304: Cannot find name 'Response'.
node_modules/apollo-client/transport/networkInterface.d.ts(43,14): error TS2304: Cannot find name 'RequestInit'.
node_modules/apollo-client/transport/networkInterface.d.ts(50,12): error TS2304: Cannot find name 'RequestInit'.
node_modules/apollo-client/transport/networkInterface.d.ts(51,49): error TS2304: Cannot find name 'RequestInit'.
node_modules/apollo-client/transport/networkInterface.d.ts(59,77): error TS2304: Cannot find name 'Response'.
node_modules/apollo-client/transport/networkInterface.d.ts(66,12): error TS2304: Cannot find name 'RequestInit'.

How to reproduce the issue:

  1. Clone: https://github.com/ForbesLindesay/apollo-client-typescript-error
  2. Run npm run build
  3. Observe that there are typescript errors, and that they're all from apollo.

Most helpful comment

You have two options:

a) add dom to tsconfig.json > compilerOptions.lib
b) install typings that contains fetch, Response and RequestInit

First option is recommended :+1:

@helfer Just so you know about it, this could be a popular topic in github issues :)

All 6 comments

You have two options:

a) add dom to tsconfig.json > compilerOptions.lib
b) install typings that contains fetch, Response and RequestInit

First option is recommended :+1:

@helfer Just so you know about it, this could be a popular topic in github issues :)

I tried it, but it doesn't work. don't know how to do it.

@kamilkisiela are there any options we can do on the Apollo slide to make this easier?

@ForbesLindesay I'm sorry you ran into this issue! I'll see if we can work to a solution!

@ForbesLindesay I cloned down the repo, removed the node_modules and ran npm i && npm run build, everything worked great for me with no errors? Could you see if you can reproduce?

This issue has been automatically marked as stale becuase it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions to Apollo Client!

This issue has been automatically closed because it has not had recent activity after being marked as stale. If you belive this issue is still a problem or should be reopened, please reopen it! Thank you for your contributions to Apollo Client!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MichaelDeBoey picture MichaelDeBoey  路  3Comments

treecy picture treecy  路  3Comments

stubailo picture stubailo  路  3Comments

skeithtan picture skeithtan  路  3Comments

rafgraph picture rafgraph  路  3Comments