-
-
Notifications
You must be signed in to change notification settings - Fork 11.6k
breaking interface change #4109
Copy link
Copy link
Closed
Description
Describe the bug
In #2995 merge request, there was introduced a bug.
There came 2 issues.
- input and output types have to be the same.
- existing usages are broken
To Reproduce
pass input and output type to axios.post
interface Input {
name: string;
}
interface Output {
value: string;
}
/* existing usages are broken
* TS2345: Argument of type '{ name: string; }' is not assignable to parameter of type 'undefined'.
*/
const { data } = await axios.post<Output>('url', {
name: 'hello',
});
/* Input and output have to be the same type
* TS2345: Argument of type '{ name: string; }' is not assignable to parameter of type 'AxiosResponse<Output>'.
* Object literal may only specify known properties, and 'name' does not exist in type 'AxiosResponse<Output>'.
*/
const { data } = await axios.post<Input, AxiosResponse<Output>>('url', {
name: 'hello',
});Expected behavior
No type errors.
Environment
- Axios Version 0.22.0
- Adapter HTTP
- Browser Chrome
- Browser Version 94.0.4606.61
- Node.js Version v14.17.5
- OS: Windows 10
- Additional Library Versions none
Additional context/Screenshots
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels