auto get Error ?
i have this code useQuery automatically getting type whatever m passing in axios type but i want to add Error type on all axios call that should get in use Query like so <IFetchResponse<Game>, Error> but instead of typing manually it should take automatically

9 Replies
deep-jadeOP•3y ago
@bostonsheraff kindly guide thanks
is it possible
deep-jadeOP•3y ago
like here m passing manually - i dont want to pass it should get whatever api return data type na

deep-jadeOP•3y ago
m not able to get Error type if i dont type manually in useQUery

deep-jadeOP•3y ago
@bostonsheraff
data result m getting fine
environmental-rose•3y ago
Sadly Typescript does not type the errors so I don't think you can do this automatically. The languages that type their errors have some form of "wrapping / unwrapping" system, like Rust's
In javascript / typescript, virtually any function can throw any type or variable and the information is not known anywhere
deep-jadeOP•3y ago
so is there any workaround ? i tried like this not working

deep-jadeOP•3y ago

deep-jadeOP•3y ago
@bostonsheraff
environmental-rose•3y ago
No workaround that I know of. Just
useQuery<TData, E> everywhere instead of useQuery<TData>, which is really just 3 characters more