Types of property 'headers' are incompatible (with new 3.1.0)
See original GitHub issue(First of all thanks for this amazing package!)
We are using cross-fetch to use the same client calls to our APIs from other APIs and any running application.
For our infrastructural needs, we created a small customFetch
function on top of the fetch
function so we could change the URL if a cloud
parameter is passed or not:
export const customFetch = (input: RequestInfo, init: RequestInit, cloud?: CloudSubdomain | string): Promise<Response> => {
let url = "";
if (cloud) {
url += createCloudUrl(cloud);
}
url += input;
return fetch(url, init);
};
After updating to version 3.1.0 our code started to throw the following error:
Type 'Promise<import("/home/user/development/node_modules/cross-fetch/lib.fetch").Response>' is not assignable to type 'Promise<Response>'.
Type 'import("/home/user/development/node_modules/cross-fetch/lib.fetch").Response' is not assignable to type 'Response'.
Types of property 'headers' are incompatible.
Type 'Headers' is missing the following properties from type 'Headers': [Symbol.iterator], entries, keys, values
22 return fetch(url, init);
I inspected the types from both node_modules/typescript/lib/lib.dom.d.ts
and node_modules/cross-fetch/lib.fetch.d.ts
and I see no difference apart from this:
declare var Headers: {
prototype: Headers;
new(init?: HeadersInit): Headers;
};
Hope you can shed some light on this. Thanks for your time!
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:17 (12 by maintainers)
Top Results From Across the Web
typescript error - Types of property 'headers' are incompatible
Types of property 'headers' are incompatible. Type 'HttpHeaders' is not assignable to type 'Headers'. Property 'forEach' is missing in type ' ...
Read more >ASP.NET Core breaking changes | Microsoft Learn
Lists the breaking changes in ASP.NET Core 3.0 and 3.1.
Read more >Configuration - Spark 3.1.1 Documentation
Spark properties mainly can be divided into two kinds: one is related to deploy, like “spark.driver.memory”, “spark.executor.instances”, this kind of ...
Read more >Jersey 3.1.0 User Guide - GitHub Pages
This is user guide for Jersey 3.1.0. We are trying to keep it up to date as we add new features. When reading...
Read more >Migrating from 2.x to 3.0 - Socket.IO
IO 3.1.0, the v3 server is now able to communicate with v2 clients. ... IO server automatically added the necessary headers to allow ......
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
🤦 Sorry again - I was trying to quickly think of a way to fix this problem and I failed to really internalize the problem before proposing a solution.
I’ve got a new approach that I think will really work. I’ll open a new PR shortly, including how I’ve tested it against the code sample in this issue.
@lquixada This is still happening for me on
3.1.2
.