I have this function which used to work in plain javascript. I am now trying to "convert" it to Typescript.
function checkStatus(response :any) {
if (response.status >= 200 && response.status < 300) {
return response;
} else {
const error = new Error(`HTTP Error ${response.statusText}`);
error.status = response.statusText;
error.response = response;
console.log(error);
throw error;
}
}
The red squiggly lines in my editor show that:
[ts] Property 'status' does not exist on type 'Error'. any
and
[ts] Property 'response' does not exist on type 'Error'. any
So is there a typescript version of the Error object defined somewhere in the Typescript land and its missing status and response fields on the Error object? Thank you