fetch is incompatible with the GlobalFetch['fetch'] type
See original GitHub issueimport fetch from "node-fetch";
let f: GlobalFetch["fetch"] = fetch;
This fails with error message:
Type '(url: string | Request, init?: RequestInit) => Promise<Response>' is not assignable to type '(input: RequestInfo, init?: RequestInit) => Promise<Response>'.
Types of parameters 'url' and 'input' are incompatible.
Type 'RequestInfo' is not assignable to type 'string | Request'.
Type 'Request' is not assignable to type 'string | Request'.
Type 'Request' is not assignable to type 'import("/Users/grant.wu/petuum/api-gateway/node_modules/@types/node-fetch/index").Request'.
Property 'context' is missing in type 'Request'.
I’m using typescript 3.1.1 and node-fetch 2.2.0.
https://github.com/apollographql/apollo-link/issues/513 this causes problems with code that assumes that GlobalFetch['fetch']
is a good type to represent a generic “fetcher”.
Do you have any suggestions for how to proceed?
Issue Analytics
- State:
- Created 5 years ago
- Comments:5
Top Results From Across the Web
fetch's type not matching when calling createHttpLink
Invariant Violation : fetch is not found globally and no fetcher passed, to fix pass a fetch for your environment like https://www.npmjs.com/ ...
Read more >FetchMode in Hibernate - Baeldung
In this short tutorial, we'll take a look at different FetchMode values we can use in the @org.hibernate.annotations.Fetch annotation.
Read more >@types/node-fetch - npm
Summary. This package contains type definitions for node-fetch (https://github.com/bitinn/node-fetch). Details.
Read more >node-fetch | Yarn - Package Manager
A light-weight module that brings Fetch API to Node.js.
Read more >SQLSTATE values and common error codes - IBM
The position of the cursor referenced in the FETCH statement was after the last row of the ... 42880, The CAST TO and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I saw
apollo-env
now has a workaround that wrapnode-fetch
into a fetch with compatible type, I think it’s the right approach, so I am closing this.@cdaringe Nope, didn’t have an alternative to what you came up with in https://github.com/apollographql/apollo-link/issues/513#issuecomment-548219023