mirror of
https://github.com/tenrok/axios.git
synced 2026-06-08 17:22:34 +03:00
Make the default type of response data never (#3002)
This requires TypeScript users to explicitly define the type of the data they are consuming. Before this, data was `any` by default. This means TypeScript consumers didn’t get type safety if they forgot to specify the type. Technically this is a breaking change for TypeScript users, as this will report errors if they forgot to specifiy the response type. The simplest workaround would be to explicitly set the response type to `any`, so it’s not breaking much. The `unknown` type is probably a slightly better fit, but this requires TypeScript ^3. `data` is still `any` in the very specific use case mentioned in https://github.com/microsoft/TypeScript/issues/38969 Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
@@ -296,7 +296,7 @@ axios.interceptors.response.use((response: AxiosResponse) => Promise.resolve(res
|
||||
// Adapters
|
||||
|
||||
const adapter: AxiosAdapter = (config: AxiosRequestConfig) => {
|
||||
const response: AxiosResponse = {
|
||||
const response: AxiosResponse<any> = {
|
||||
data: { foo: 'bar' },
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
|
||||
Reference in New Issue
Block a user