Change headers type to string record#3021
Conversation
e0375c5 to
19a7591
Compare
|
@jasonsaayman Could you also have a look at this please? 😃 I’m also tagging @TimWolla because of their involvement in #2797 This forces TypeScript users to use objects whose values are strings as headers. I.e., currently the following is allowed: import axios from 'axios';
axios.post('', {}, { headers: 'Invalid' })
axios.post('', {}, { headers: 13 })
axios.post('', {}, { headers: [] })
axios.post('', {}, { headers: { authorization: [] } })
// etc…This changes the types, so only proper authorization headers are allowed, and the response header types are correct as well. import axios from 'axios';
axios.post('', {}, { headers: { authorization: 'A string :)' } })I don’t consider this to be a breaking change, as it still works the same for proper usage. |
TimWolla
left a comment
There was a problem hiding this comment.
TIL about the Record type.
I don’t consider this to be a breaking change, as it still works the same for proper usage.
This is technically a breaking change, but only in a regard that it will find an actual bug in a consumer's code. TypeScript users will certainly appreciate the increased strictness in typing.
This correctly reflects the type in a more type safe manner.
19a7591 to
32619dd
Compare
This correctly reflects the type in a more type safe manner. Co-authored-by: Jay <[email protected]>
This correctly reflects the type in a more type safe manner.