restyped-axios icon indicating copy to clipboard operation
restyped-axios copied to clipboard

URLs aren't statically checked when using `.get(…)`, `.post(…)`, etc

Open wolever opened this issue 6 years ago • 0 comments

Because the definitions of get(…), post(…), etc use Path | string, invalid paths aren't checked:

So, for example, this will compile without issue:

interface MyAPI {
  '/foo': {}
}

let api = axios.create<MyAPI>()
api.get('/bar') // <-- compiles

I realize that this is necessary to support paths with query parameters… but it should really be noted in the documentation, because it's pretty surprising :)

wolever avatar Apr 12 '18 02:04 wolever