Deno: ErrorConstructor.captureStackTrace missing in TypeScript definitions

Created on 10 Apr 2020  Â·  5Comments  Â·  Source: denoland/deno

Example

// test.ts
const error = new Error("Example");
Error.captureStackTrace(error);
throw error;

Expected run result

Successful typecheck and output of

error: Uncaught Error: Example
â–º file:///tmp/test.ts:2:7

2 Error.captureStackTrace(error);
        ^

    at file:///tmp/test.ts:2:7

(As if the above code were in a file named test.js)

Actual run result

error TS2339: Property 'captureStackTrace' does not exist on type 'ErrorConstructor'.

â–º file:///tmp/test.ts:2:7

2 Error.captureStackTrace(error);
        ~~~~~~~~~~~~~~~~~

System

> deno --version
deno 0.40.0
v8 8.2.308
typescript 3.8.3
bug

Most helpful comment

captureStackTrace is not a standard property, so that it why it isn't included in the standard TypeScript libraries. It is perfectly fine to do in Deno, as it is a v8 thing, and we will always be off v8.

All 5 comments

Just to be clear, it works in JS?

Yes, it works in JS.

Someone told me that it was a typescript thing, that it doesn't work using typescript. Not specific to deno. But this should be verified.

captureStackTrace is not a standard property, so that it why it isn't included in the standard TypeScript libraries. It is perfectly fine to do in Deno, as it is a v8 thing, and we will always be off v8.

Oh, fixed in #5254.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zugende picture zugende  Â·  3Comments

somombo picture somombo  Â·  3Comments

CruxCv picture CruxCv  Â·  3Comments

justjavac picture justjavac  Â·  3Comments

motss picture motss  Â·  3Comments