Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

Missing typings #544

Closed
1 of 4 tasks
itsJess1ca opened this issue Mar 12, 2018 · 3 comments
Closed
1 of 4 tasks

Missing typings #544

itsJess1ca opened this issue Mar 12, 2018 · 3 comments
Labels
has-reproduction ❤ Has a reproduction in a codesandbox or single minimal repository

Comments

@itsJess1ca
Copy link

itsJess1ca commented Mar 12, 2018

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

  • has-reproduction
  • feature
  • blocking
  • good first issue
@ghost ghost added the has-reproduction ❤ Has a reproduction in a codesandbox or single minimal repository label Mar 12, 2018
@evans
Copy link
Contributor

evans commented Mar 27, 2018

@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?

@evans evans closed this as completed Mar 27, 2018
@itsJess1ca
Copy link
Author

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 👍

Thanks for a great package, It's been a huge help in getting things done quickly :)

@vincenzo
Copy link

vincenzo commented Oct 12, 2018

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.

nebolsin added a commit to astroband/astrograph that referenced this issue Jan 17, 2019
hmmhmmhm added a commit to hmmhmmhm/common-gql that referenced this issue May 25, 2019
yaacovCR added a commit to yaacovCR/graphql-tools-fork that referenced this issue Feb 23, 2020
@types/supertest was also hiding need for explicit inclusion of dom within typescript libs to avoid apollo-link-http-common related errors on node, see
#41 and apollographql/apollo-link#544
yaacovCR added a commit to yaacovCR/graphql-tools-fork that referenced this issue Feb 27, 2020
@types/supertest was also hiding need for explicit inclusion of dom within typescript libs to avoid apollo-link-http-common related errors on node, see
#41 and apollographql/apollo-link#544
yaacovCR added a commit to yaacovCR/graphql-tools-fork that referenced this issue Mar 26, 2020
@types/supertest was also hiding need for explicit inclusion of dom within typescript libs to avoid apollo-link-http-common related errors on node, see
#41 and apollographql/apollo-link#544
yaacovCR added a commit to yaacovCR/graphql-tools-fork that referenced this issue Mar 26, 2020
@types/supertest was also hiding need for explicit inclusion of dom within typescript libs to avoid apollo-link-http-common related errors on node, see
#41 and apollographql/apollo-link#544
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
has-reproduction ❤ Has a reproduction in a codesandbox or single minimal repository
Projects
None yet
Development

No branches or pull requests

3 participants