// test.ts
const error = new Error("Example");
Error.captureStackTrace(error);
throw error;
run resultSuccessful 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)
run resulterror TS2339: Property 'captureStackTrace' does not exist on type 'ErrorConstructor'.
â–º file:///tmp/test.ts:2:7
2 Error.captureStackTrace(error);
~~~~~~~~~~~~~~~~~
> deno --version
deno 0.40.0
v8 8.2.308
typescript 3.8.3
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.
Most helpful comment
captureStackTraceis 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.