refactor: use built-in Error.isError - #2892
Conversation
Jason Morse (JasonVMo)
left a comment
There was a problem hiding this comment.
Should we create a wrapper abstraction like?:
export function isError(e: unknown): e is Error {
return e != null && (e as { isError?: unknown }).isError || e instanceof Error);
}Generally we can catch the truthy value of isError which will match the new behavior but fall through to the older instance of behavior. It seems like the isError check effectively widens the type.
For this scenario specifically, we can use react-native-test-app/packages/app/windows/project.mjs Lines 36 to 38 in a924b3a Which can benefit from being replaced with |
Description
Use built-in
Error.isErrorinstead ofinstanceof.Note that this was recently introduced in Node 24.3. We cannot use it in public-facing code.
Platforms affected
Test plan
n/a