2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-05 16:42:32 +03:00

fix(types): restore AxiosError.cause type from unknown to Error (#7327)

* Initial plan

* fix(types): restore AxiosError.cause type from unknown to Error

Co-authored-by: jasonsaayman <4814473+jasonsaayman@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: jasonsaayman <4814473+jasonsaayman@users.noreply.github.com>
This commit is contained in:
Copilot
2026-01-12 16:20:00 +02:00
committed by GitHub
parent 5945e40bb1
commit d8233d9e8e
3 changed files with 11 additions and 2 deletions
+9
View File
@@ -720,3 +720,12 @@ axios.get('/user', {
return ['127.0.0.1', 4];
}
});
// AxiosError.cause should be typed as Error to allow accessing .message
axios.get('/user').catch((error: AxiosError) => {
if (error.cause) {
// This should not produce a type error - cause is typed as Error
const causeMessage: string | undefined = error.cause.message;
console.log(causeMessage);
}
});