---
title: "Discussion on \"How to Fix instanceof Not Working For Custom Errors in TypeScript\" | Hashnode"
description: "Discussion on \"How to Fix instanceof Not Working For Custom Errors in TypeScript\". In JavaScript, you can create custom errors by extending the built-in Error object (ever since ES 2015).\nclass DatabaseError extends Error {}\n\nYou can do the same thing in TypeScript, but there is an important caveat if your tsconfig.json has a compi..."
url: "https://hashnode.com/posts/how-to-fix-instanceof-not-working-for-custom-errors-in-typescript/609bdc53c798bd79ff8edc50"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [How to Fix instanceof Not Working For Custom Errors in TypeScript](https://dguo.hashnode.dev/how-to-fix-instanceof-not-working-for-custom-errors-in-typescript?utm_source=hashnode&utm_medium=feed)

In JavaScript, you can create custom errors by extending the built-in Error object (ever since ES 2015). class DatabaseError extends Error {} You can do the same thing in TypeScript, but there is an important caveat if your tsconfig.json has a compi...

Apr 18, 2021 · 2 min read · dguo.hashnode.dev  
Read the article

-   [#typescript](https://hashnode.com/tag/typescript)
-   [#error-handling](https://hashnode.com/tag/error-handling)

## Written by

[Danny Guo](https://hashnode.com/@dguo)

@dguo

  
[View profile](https://hashnode.com/@dguo)

Software engineer

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
