Skip to content
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

fix: DefaultOptions typing was wrong [EXT-6172] #530

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,9 @@ export { default as toPlainObject } from './to-plain-object.js'
export { default as errorHandler } from './error-handler.js'
export { default as createDefaultOptions } from './create-default-options.js'

export type { AxiosInstance, CreateHttpClientParams, DefaultOptions } from './types.js'
export type {
AxiosInstance,
CreateHttpClientParams,
DefaultOptions,
InstanceDefaults,
} from './types.js'
8 changes: 7 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type {
AxiosInstance as OriginalAxiosInstance,
AxiosRequestConfig,
AxiosResponse,
HeadersDefaults,
} from 'axios'

export type DefaultOptions = AxiosRequestConfig & {
Expand All @@ -13,10 +14,15 @@ export type DefaultOptions = AxiosRequestConfig & {
retryOnError?: boolean
}

export type InstanceDefaults = Omit<DefaultOptions, 'headers'> & {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

headers: HeadersDefaults & {
[key: string]: AxiosHeaderValue
}
}
export type AxiosInstance = OriginalAxiosInstance & {
httpClientParams: CreateHttpClientParams
cloneWithNewParams: (params: Partial<CreateHttpClientParams>) => AxiosInstance
defaults: DefaultOptions
defaults: InstanceDefaults
}

export type CreateHttpClientParams = {
Expand Down