Wrong instance of error in ES5
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:
class Error_ {
name: string;
message: string;
readonly stack?: string;
constructor(message: string) {
this.name = 'Error';
this.message = message;
this.stack = (new Error()).stack;
}
}
export class NetworkError extends Error_

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 https://github.com/microsoft/TypeScript/issues/10166 But seems like this repo is no longer maintained :( @anilanar Don't really think it would be better in such context. Also, creating new error types by inheritance is a very popular and well-used way in JavaScript
@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 Error when pattern matching with instanceof. Just something to keep in mind.
Ah nevermind, you are actually using a union type for the error.