-
Notifications
You must be signed in to change notification settings - Fork 13.4k
feat: add Error.isError() to ESNext lib #60788
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,9 @@ | ||
| /// <reference lib="es2024" /> | ||
| /// <reference lib="esnext.intl" /> | ||
| /// <reference lib="esnext.array" /> | ||
| /// <reference lib="esnext.collection" /> | ||
| /// <reference lib="esnext.decorators" /> | ||
| /// <reference lib="esnext.disposable" /> | ||
| /// <reference lib="esnext.collection" /> | ||
| /// <reference lib="esnext.array" /> | ||
| /// <reference lib="esnext.error" /> | ||
| /// <reference lib="esnext.intl" /> | ||
| /// <reference lib="esnext.iterator" /> | ||
| /// <reference lib="esnext.promise" /> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| interface ErrorConstructor { | ||
| /** | ||
| * Indicates whether the argument provided is a built-in Error instance or not. | ||
| */ | ||
| isError(error: unknown): error is Error; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note, in the spec, this is not a predicate on satisfying the shape of the Error prototype. const pseudo = Reflect.construct(Error, [], Object)
Error.prototype.isPrototypeOf(pseudo) // false
'message' in pseudo // false
'name' in pseudo // false
Error.isError(pseudo) // trueBy rights, this should really just return a boolean.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It being a predicate was the main reason everyone wanted it....
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (okay the realm problem is the real issue but still)
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The usefulness very much outweighs the downsides, we think. |
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.