Describe the bug
wreq-js is very nearly type compatible with the native fetch function but not quite, meaning it can't be used as a drop in replacement in situations which accept a fetch client without throwing typescript errors.
Thanks for maintaining such a useful library by the way!
Reproduction
https://stackblitz.com/edit/vitejs-vite-msdyarep?file=index.ts&terminal=dev
(as the first comment mentions, once the webcontainer has finished loading if you're still not seeing errors highlighted then you might need to make some minor change to the file to get it to show).
Error output
Argument of type '(input: string | URL | Request, init?: RequestInit) => Promise<Response>' is not assignable to parameter of type '(input: URL | RequestInfo, init?: RequestInit) => Promise<Response>'.
Types of parameters 'init' and 'init' are incompatible.
Type 'RequestInit' is not assignable to type 'import("node_modules/wreq-js/dist/wreq-js").RequestInit'.
Types of property 'headers' are incompatible.
Type 'HeadersInit' is not assignable to type 'import("node_modules/wreq-js/dist/wreq-js").HeadersInit'.
Type 'Headers' is not assignable to type 'HeadersInit'.
Type 'Headers' is not assignable to type 'Record<string, string | number | boolean>'.
Index signature for type 'string' is missing in type 'Headers'.(2345)
and
Argument of type '(input: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>' is not assignable to parameter of type '{ (input: URL | RequestInfo, init?: RequestInit | undefined): Promise<Response>; (input: string | URL | Request, init?: RequestInit | undefined): Promise<...>; }'.
Types of parameters 'init' and 'init' are incompatible.
Type 'RequestInit | undefined' is not assignable to type 'import("/Users/callumgare/repos/liase/node_modules/wreq-js/dist/wreq-js", { with: { "resolution-mode": "import" } }).RequestInit | undefined'.
Type 'RequestInit' is not assignable to type 'import("/Users/callumgare/repos/liase/node_modules/wreq-js/dist/wreq-js", { with: { "resolution-mode": "import" } }).RequestInit'.
Types of property 'body' are incompatible.
Type 'BodyInit | null | undefined' is not assignable to type 'import("/Users/callumgare/repos/liase/node_modules/wreq-js/dist/wreq-js", { with: { "resolution-mode": "import" } }).BodyInit | null | undefined'.
Type 'ReadableStream<any>' is not assignable to type 'BodyInit | null | undefined'.
Type 'ReadableStream<any>' is missing the following properties from type 'FormData': append, delete, get, getAll, and 6 more.ts(2345)
and
Argument of type 'import("node_modules/wreq-js/dist/wreq-js").Response' is not assignable to parameter of type 'Response'.
Types of property 'headers' are incompatible.
Property 'getSetCookie' is missing in type 'import("node_modules/wreq-js/dist/wreq-js").Headers' but required in type 'Headers'.(2345)
wreq-js version
2.3.1 (latest)
Runtime
v22.22.3
OS
macOS (Apple Silicon)
Additional context
No response
Describe the bug
wreq-js is very nearly type compatible with the native fetch function but not quite, meaning it can't be used as a drop in replacement in situations which accept a fetch client without throwing typescript errors.
Thanks for maintaining such a useful library by the way!
Reproduction
Error output
wreq-js version
2.3.1 (latest)
Runtime
v22.22.3
OS
macOS (Apple Silicon)
Additional context
No response