Skip to content

Add @types/node-fetch to apollo-env deps since they are exported#1749

Merged
trevor-scheer merged 2 commits intomasterfrom
trevor/node-fetch-types
Jan 9, 2020
Merged

Add @types/node-fetch to apollo-env deps since they are exported#1749
trevor-scheer merged 2 commits intomasterfrom
trevor/node-fetch-types

Conversation

@trevor-scheer
Copy link
Copy Markdown
Contributor

@trevor-scheer trevor-scheer commented Jan 8, 2020

This PR is in response to apollographql/apollo-server#3580. Currently, dependents of apollo-env can expect TS build errors if @types/node-fetch isn't included transitively. This affects the entire apollo-server-* family via apollo-server-core, as seen in this dependency tree:

apollo-example@1.0.0
└─┬ apollo-server-express@2.9.15
  └─┬ apollo-server-core@2.9.15
    ├─┬ @apollographql/apollo-tools@0.4.2
    │ └── apollo-env@0.6.0 
    └─┬ apollo-engine-reporting@1.4.13
      └─┬ apollo-graphql@0.3.6
        └── apollo-env@0.6.0  deduped

The build error when trying to install apollo-server-express in a typescript project:

% npx tsc
node_modules/apollo-env/lib/fetch/fetch.d.ts:6:195 - error TS7016: Could not find a declaration file for module 'node-fetch'. '/Users/trevorscheer/Desktop/example/node_modules/node-fetch/lib/index.js' implicitly has an 'any' type.
  Try `npm install @types/node-fetch` if it exists or add a new declaration (.d.ts) file containing `declare module 'node-fetch';`

6 export { default as fetch, Request, Response, Headers, ResponseInit, BodyInit, RequestInfo, HeadersInit, Body, RequestInit, RequestMode, RequestCredentials, RequestCache, RequestRedirect } from "node-fetch";

Exporting these^ from the root of apollo-env like this requires that apollo-env should list the @types/node-fetch as a project dependency.

TODO:

  • Update CHANGELOG.md* with your change (include reference to issue & this PR)
  • Make sure all of the significant new logic is covered by tests
  • Rebase your changes on master so that they can be merged easily
  • Make sure all tests and linter rules pass

*Make sure changelog entries note which project(s) has been affected. See older entries for examples on what this looks like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants