-
-
Notifications
You must be signed in to change notification settings - Fork 612
Open
Labels
bugSomething isn't workingSomething isn't workingopenapi-fetchRelevant to the openapi-fetch libraryRelevant to the openapi-fetch library
Description
openapi-fetch version
0.15.0
Description
When using undici's fetch and Request for the custom fetch and Request options, I get typescript errors. Looking at previous pull requests, it looks like this should be supported, so I assume this is a bug:
- feat(openapi-fetch): allow usage of custom Request class #1907
- Use overridable fetch instead of unidici's request #1002
Reproduction
import createClient from "openapi-fetch";
import { Request, fetch } from "undici";
export const client = createClient({
fetch,
Request,
});Results in 2 typescript issues:
Type '(input: RequestInfo, init?: RequestInit | undefined) => Promise<Response>' is not assignable to type '(input: Request) => Promise<Response>'.
Types of parameters 'input' and 'input' are incompatible.
Type 'Request' is not assignable to type 'RequestInfo'.
Property 'duplex' is missing in type 'Request' but required in type 'import("/node_modules/undici/types/fetch").Request'.ts(2322)Type 'typeof Request' is not assignable to type '{ new (input: RequestInfo | URL, init?: RequestInit | undefined): Request; prototype: Request; }'.
Types of property 'prototype' are incompatible.
Property 'bytes' is missing in type 'import("/node_modules/undici/types/fetch").Request' but required in type 'Request'.ts(2322)Expected result
Using fetch and Request from undici should not result in typescript errors.
Extra
- I’m willing to open a PR (see CONTRIBUTING.md)
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingopenapi-fetchRelevant to the openapi-fetch libraryRelevant to the openapi-fetch library