-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
doesn't work if error is {}
or unknown
#23
Comments
I guess you cannot resolve the issue on the library level. if (error) ... is the same as if (!!error) ... So, in the So, the solution in TypeScript for case - if(error) ...
+ if(error != null) However, The difference between In general, we need the |
oh, it just means that your library doesn't support non-Error exceptions ) export type TupleResult<T, E extends Error = Error> = [E] | [null, T] and so on. |
As it should right? No one expects non-Error exceptions either way, so in case any of them is thrown we have a good wrapper to catch it. And for the people who use |
Say that to vercel with their nextjs UPD: I've checked out. I was wrong. nextjs and react throw instances of Error class augmented with their internal data. But these exceptions are not "real exceptions", they are used to control flow ) As instance React throws error with the following message:
|
RE: React & Next, would it be possible to provide some configuration to the matcher for TupleItError so that you can rethrow if the error matches based on a callbackFn predicate you provide? For example, Next.js extends Error and adds a digest property set to specific values... For react, you may have to match a pattern against the string in Error.message property, which is not great. If some error middleware was provided that knows to rethrow specific magic errors, you should be able to configure it for your particular environment. |
About the
tuple-it
library. It works iferror
is of typeError
or something like that.The library doesn't work if error is
{}
orunknown
:Typescript in strict mode treats exceptions as
unknown
by default, so semantically to use something else doesn't seem to be correct.Originally posted by @DScheglov in arthurfiorette/proposal-safe-assignment-operator#3 (comment)
The text was updated successfully, but these errors were encountered: