Skip to content

Commit

Permalink
Change Options and NormalizedOptions types back to be interface
Browse files Browse the repository at this point in the history
Fixes #523
  • Loading branch information
sindresorhus committed Sep 5, 2023
1 parent 60e4f67 commit 4d63a21
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions source/types/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export type KyHeadersInit = HeadersInit | Record<string, string | undefined>;
/**
Options are the same as `window.fetch`, with some exceptions.
*/
export type Options = {
export interface Options extends Omit<RequestInit, 'headers'> { // 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`.
/**
HTTP method used to make the request.
Expand Down Expand Up @@ -221,7 +221,7 @@ export type Options = {
```
*/
fetch?: (input: RequestInfo, init?: RequestInit) => Promise<Response>;
} & Omit<RequestInit, 'headers'>;
}

export type InternalOptions = Required<
Omit<Options, 'hooks' | 'retry'>,
Expand All @@ -236,7 +236,7 @@ Omit<Options, 'hooks' | 'retry'>,
/**
Normalized options passed to the `fetch` call and the `beforeRequest` hooks.
*/
export type NormalizedOptions = {
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'];
Expand All @@ -245,6 +245,6 @@ export type NormalizedOptions = {
retry: RetryOptions;
prefixUrl: string;
onDownloadProgress: Options['onDownloadProgress'];
} & RequestInit;
}

export type {RetryOptions} from './retry.js';

0 comments on commit 4d63a21

Please sign in to comment.