기존 프로젝트의 axiosInstance의 타입들이 Definite Assigment Aeesrtions 또는 Non-null assertion opertator를 통해 단언이 된 것을 확인하여 커스텀 타입을 정의하였다.
import {
AxiosHeaders as OriginAxiosHeaders,
AxiosInstance as OriginAxiosInstance,
AxiosInterceptorManager,
AxiosResponse,
InternalAxiosRequestConfig,
} from 'axios';
type AxiosHeaders = OriginAxiosHeaders & {
[key: string]: string | undefined;
};
export interface AxiosRequestConfig extends InternalAxiosRequestConfig {
headers: AxiosHeaders;
}
export interface CustomInstance extends OriginAxiosInstance {
interceptors: {
request: AxiosInterceptorManager<AxiosRequestConfig>;
response: AxiosInterceptorManager<AxiosResponse>;
};
}
axiosInstance.ts