Skip to content

Instantly share code, notes, and snippets.

@yaakaito
Created December 10, 2019 14:39
Show Gist options
  • Save yaakaito/04a07fc2f121cf8cb9b25ce47bdc7434 to your computer and use it in GitHub Desktop.
Save yaakaito/04a07fc2f121cf8cb9b25ce47bdc7434 to your computer and use it in GitHub Desktop.
TypeScript で instaceof できる Error 作るやつ
class MyError extends Error {
constructor(message: string) {
super(message)
this.name = new.target.name
Object.setPrototypeOf(this, new.target.prototype)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment