-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
When trying to use this library
try {
return await this.exampleRepository.save(input);
} catch (error) {
const wrapped = wrapError(error);
if (wrapped instanceof UniqueViolationError) {
throw new ExampleAlreadyExists(wrapped);
}
throw error;
}TypeScript complains because error is of type unknown rather than Error
const wrapped = wrapError(error);
// ^^^^^
// Argument of type 'unknown' is not assignable to parameter of type 'Error'.Because of changes in TypeScript 4.4
https://devblogs.microsoft.com/typescript/announcing-typescript-4-4/#use-unknown-catch-variables
User needs to cast the error to Error, however, it does not seem that the code would fail if the error were any other type, so perhaps the typescript d.ts can be changed?
Metadata
Metadata
Assignees
Labels
No labels