node-fetch icon indicating copy to clipboard operation
node-fetch copied to clipboard

Type conflict when using vscode with node-fetch

Open mwoodpatrick opened this issue 4 years ago • 3 comments

I'm creating a nextjs app using vscode on Ubuntu 20.04 (WSL-2) in typescript and using Apollo Client & node-fetch. I'm getting a compile error:

Type 'Promise<import("/home/mwoodpatrick/projects/git/www/blog-series-nextjs-nx/node_modules/@types/node-fetch/index").Response>' is not assignable to type 'Promise<Response>'. Type 'Response' is missing the following properties from type 'Response': trailer, formData

It appears that there are incompatible definitions of "Promise<Response>"

https://github.com/microsoft/TypeScript/blob/main/lib/lib.dom.d.ts

versus

https://github.com/node-fetch/node-fetch/blob/main/%40types/index.d.ts

I would appreciate any suggestions on how to avoid this type of conflict.

mwoodpatrick avatar Sep 11 '21 18:09 mwoodpatrick

Hi @mwoodpatrick , can you share your imports? I think I know the issue.

schimini avatar Jun 06 '22 19:06 schimini

I'm running into the same issue here and see that the OP never responded. @schimini is there a particular import that you're looking for?

I have the following

import { ApiError } from "./ApiError";
import type { ApiRequestOptions } from "./ApiRequestOptions";
import type { ApiResult } from "./ApiResult";
import { OpenAPI } from "./OpenAPI";
import fetch from "node-fetch";

CWSites avatar Mar 24 '23 19:03 CWSites