Typescript - Extending Error class
<p>I'm trying to throw a custom error with my "CustomError" class name printed in the console instead of "Error", with no success:</p>

<pre><code>class CustomError extends Error { 
    constructor(message: string) {
      super(`Lorem "${message}" ipsum dolor.`);
      this.name = 'CustomError';
    }
}
throw new CustomError('foo'); 
</code></pre>

<p>The output is <code>Uncaught Error: Lorem "foo" ipsum dolor</code>.</p>

<p>What I expect: <code>Uncaught CustomError: Lorem "foo" ipsum dolor</code>. </p>

<p>I wonder if that can be done using TS only (without messing with JS prototypes)?</p>