-
Notifications
You must be signed in to change notification settings - Fork 4
Wrong instance of error in ES5 #3
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
Comments
I'm also encountering this, and it's a dealbreaker. Another option is to leave it as ES6? |
Wouldn't it be better to use a tagged union type for errors instead of using prototype inheritence? |
Actually, I think a better way of resolving that issue: using the babel transpiler(maybe with a bundler like webpack), because it an issue of TypeScript compiler microsoft/TypeScript#10166 |
@PunGy That's true in Javascript (and possibly also Typescript) but perhaps not in "fp-ts" ecosystem simply because pattern matching on the error type can never be exhaustive because the type system doesn't know all possible subtypes of Ah nevermind, you are actually using a union type for the error. |
Custom fetcher errors from
error.ts
are inherit as ES6 class from the basic Error class.It's okey in ES6, but when it transpiles to es5 - basic function inheritance throws error before we correctly define out class. And because of that, for example
const error = new NetworkError ('Some troubles')
is not the instance of NetworkError, it's always instance of Error.One of possible decisions - create custom general Error class which isn't automaticaly throw:
The text was updated successfully, but these errors were encountered: