When using a React-Query mutation, I have a component that displays an error message. but Typescript doesn't recognize the mutation.error property as type Error:
if (mutation.isError){
console.log(mutation.error.message); // Property 'message' does not exist on type 'unknown'.
console.log((mutation.error as Error).message); // works
}
How can I inform typescript that mutation.error is indeed an Error object?