deno icon indicating copy to clipboard operation
deno copied to clipboard

DisposableStack is not implemented

Open sigmaSd opened this issue 2 years ago • 5 comments

The types are there, but it fails at runtime https://github.com/denoland/deno/blob/edeccef4990598620bf5595df6fc8c1b1b1a7f73/cli/tsc/dts/lib.esnext.disposable.d.ts#L53

sigmaSd avatar Oct 07 '23 19:10 sigmaSd

Also for AsyncDisposableStack.

@lucacasonato Shouldn't situations like this — where compiling (type-checking) succeeds, but the compiled JavaScript result fails at runtime — be labelled as https://github.com/denoland/deno/labels/bug?

jsejcksn avatar Jan 25 '24 09:01 jsejcksn

This bug is still present in Deno v1.40.5.

And I agree, this seems like a bug. The VSCode extension and deno check don't give any error about using DisposableStack even though it's not implemented and not even a valid identifier in scope.

NfNitLoop avatar Feb 21 '24 15:02 NfNitLoop

Just fyi. I'm using the following polyfill and it seems working OK. (thanks to https://deno.land/x/dispose)

import {
  AsyncDisposableStack,
  DisposableStack,
} from "https://deno.land/x/[email protected]/mod.ts";

// DisposableStack and AsyncDisposableStack are not available yet.
// https://github.com/denoland/deno/issues/20821

// deno-lint-ignore no-explicit-any
(globalThis as any).DisposableStack ??= DisposableStack;
// deno-lint-ignore no-explicit-any
(globalThis as any).AsyncDisposableStack ??= AsyncDisposableStack;
  • GitHub: https://github.com/nberlette/dispose

lambdalisue avatar Mar 05 '24 06:03 lambdalisue

Bumping this. This issue is present on the latest canary version as of writing.

My deno --version:

deno 1.43.2+19c0633 (canary, aarch64-apple-darwin)
v8 12.4.254.12
typescript 5.4.5

ben-laird avatar May 09 '24 22:05 ben-laird

There's been some movement on this one in the past weeks in V8: https://issues.chromium.org/issues/42203506

We will update to the version that implements DisposableStack as soon as possible.

bartlomieju avatar May 09 '24 22:05 bartlomieju