-
-
Notifications
You must be signed in to change notification settings - Fork 366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make types compatible with both DOM and Node.js #543
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,8 @@ export type DownloadProgress = { | |
totalBytes: number; | ||
}; | ||
|
||
export type KyHeadersInit = HeadersInit | Record<string, string | undefined>; | ||
// Not HeadersInit directly because @types/node doesn't export it | ||
export type KyHeadersInit = NonNullable<RequestInit['headers']> | Record<string, string | undefined>; | ||
|
||
/** | ||
Custom Ky options | ||
|
@@ -177,7 +178,7 @@ export type KyOptions = { | |
const json = await ky('https://example.com', {fetch}).json(); | ||
``` | ||
*/ | ||
fetch?: (input: RequestInfo, init?: RequestInit) => Promise<Response>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is breaking, but actually both |
||
fetch?: (input: Input, init?: RequestInit) => Promise<Response>; | ||
}; | ||
|
||
/** | ||
|
@@ -251,8 +252,8 @@ Normalized options passed to the `fetch` call and the `beforeRequest` hooks. | |
*/ | ||
export interface NormalizedOptions extends RequestInit { // eslint-disable-line @typescript-eslint/consistent-type-definitions -- This must stay an interface so that it can be extended outside of Ky for use in `ky.create`. | ||
// Extended from `RequestInit`, but ensured to be set (not optional). | ||
method: RequestInit['method']; | ||
credentials: RequestInit['credentials']; | ||
method: NonNullable<RequestInit['method']>; | ||
credentials: NonNullable<RequestInit['credentials']>; | ||
Comment on lines
+255
to
+256
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
// Extended from custom `KyOptions`, but ensured to be set (not optional). | ||
retry: RetryOptions; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't appear to be needed?