Expected Behavior
Successful build when running tsc
Actual Behavior
tsc throws the following error:
node_modules/apollo-link-http-common/lib/index.d.ts(3,15): error TS2304: Cannot find name 'Response'.
node_modules/apollo-link-http-common/lib/index.d.ts(8,15): error TS2304: Cannot find name 'Response'.
node_modules/apollo-link-http-common/lib/index.d.ts(37,13): error TS2304: Cannot find name 'GlobalFetch'.
node_modules/apollo-link-http-common/lib/index.d.ts(53,81): error TS2304: Cannot find name 'Response'.
node_modules/apollo-link-http-common/lib/index.d.ts(54,54): error TS2304: Cannot find name 'RequestInfo'.
node_modules/apollo-link-http-common/lib/index.d.ts(54,74): error TS2304: Cannot find name 'RequestInit'.
node_modules/apollo-link-http-common/lib/index.d.ts(54,98): error TS2304: Cannot find name 'Response'.
A _simple_ reproduction
src/index.ts
import 'isomorphic-unfetch';
import { ApolloClient } from 'apollo-client';
import { createHttpLink } from 'apollo-link-http';
import { InMemoryCache } from 'apollo-cache-inmemory';
export const apolloClient = new ApolloClient({
link: createHttpLink({
uri: process.env.API_ENDPOINT
}),
cache: new InMemoryCache()
});
tsconfig.json
{
"compilerOptions": {
"outDir": "build",
"target": "es6",
"module": "commonjs",
"moduleResolution": "node",
"lib": [
"esnext.asynciterable",
"es2015",
"es2016",
"es7"
],
"sourceMap": true
},
"include": [
"src/**/*.ts"
],
"exclude": [
"node_modules/",
"**/*.spec.ts"
]
}
Issue Labels
@j3ddesign Thank you for opening the issue! Take a look at this repo, specifically this commit. It adds dom
to the lib, which contains those types. Or you can set your compile option's target
to es5 or es6, which will also include those dom as well. How can we help make this more clear? Is there a section in the docs that you would like to see?
Ah interesting. I'm using this in a node project so hadn't added dom
to my tsconfig.
In regards to making it more clear, It may help to have it mentioned in the Installation
paragraph at https://www.apollographql.com/docs/link/#installation
That's the first page I went to when attempting to troubleshoot this :+1:
Thanks for a great package, It's been a huge help in getting things done quickly :)
Having es5
or es6
as compiler's target won't fix the issue (plus, @j3ddesign did have es6
as target to begin with). Adding dom
to lib
, though, did fix it.
Most helpful comment
Having
es5
ores6
as compiler's target won't fix the issue (plus, @j3ddesign did havees6
as target to begin with). Addingdom
tolib
, though, did fix it.