-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed as not planned
Description
Hey 👋
In the utils/is
file we have some helpers to check identities, but all functions just return boolean. What about using TS typeguard for that?
For example with the isError
function:
export function isError(wat: any): boolean {...}
// become
export function isError(wat: any): wat is Error {...}
Then it will allow to do:
// myException type is: string | Error
if (!isError(myException)) {
return event;
}
// previously we got the error: Property "name" doesn't exist on type string
const name = myException.name // no more need to cast to continue using it as an Error
What do you think?
This might be a big change internally (or not) since those are utils helpers and used everywhere but I could help if you need some PRs :)