Skip to content

Commit

Permalink
Fix request types for use with Node.js (#578)
Browse files Browse the repository at this point in the history
  • Loading branch information
jliuhtonen committed Apr 22, 2024
1 parent 7760a81 commit 10a4ec7
Showing 1 changed file with 47 additions and 6 deletions.
53 changes: 47 additions & 6 deletions source/types/request.ts
@@ -1,15 +1,56 @@
/*
Undici types need to be here because they are not exported to globals by @types/node.
See https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/69408
After the types are exported to globals, the Undici types can be removed from here.
*/

type UndiciHeadersInit =
| string[][]
| Record<string, string | readonly string[]>
| Headers;

type UndiciBodyInit =
| ArrayBuffer
| AsyncIterable<Uint8Array>
| Blob
| FormData
| Iterable<Uint8Array>
| NodeJS.ArrayBufferView
| URLSearchParams
// eslint-disable-next-line @typescript-eslint/ban-types
| null
| string;

type UndiciRequestRedirect = 'error' | 'follow' | 'manual';

type UndiciRequestCredentials = 'omit' | 'include' | 'same-origin';

type UndiciReferrerPolicy =
| ''
| 'no-referrer'
| 'no-referrer-when-downgrade'
| 'origin'
| 'origin-when-cross-origin'
| 'same-origin'
| 'strict-origin'
| 'strict-origin-when-cross-origin'
| 'unsafe-url';

type UndiciRequestMode = 'cors' | 'navigate' | 'no-cors' | 'same-origin';

type UndiciRequestInit = {
method?: string;
keepalive?: boolean;
headers?: HeadersInit;
body?: BodyInit;
redirect?: RequestRedirect;
headers?: UndiciHeadersInit;
body?: UndiciBodyInit;
redirect?: UndiciRequestRedirect;
integrity?: string;
signal?: AbortSignal | undefined;
credentials?: RequestCredentials;
mode?: RequestMode;
credentials?: UndiciRequestCredentials;
mode?: UndiciRequestMode;
referrer?: string;
referrerPolicy?: ReferrerPolicy;
referrerPolicy?: UndiciReferrerPolicy;
window?: undefined;
dispatcher?: unknown;
duplex?: unknown;
Expand Down

0 comments on commit 10a4ec7

Please sign in to comment.