/** * Well-known `Symbol.dispose`. Resolves to the native well-known symbol when * the runtime ships the explicit resource management proposal; otherwise falls * back to `Symbol.for('Symbol.dispose')`, the same registry symbol used by the * fallback stacks below, so `DisposableStack#use` finds the method. * * Consumers should key dispose methods on this constant — * `class Foo { [disposeSymbol]() {} }` — rather than `Symbol.dispose`, so the * class works on runtimes without the proposal. */ export declare const disposeSymbol: unique symbol; /** * Well-known `Symbol.asyncDispose`. See {@link disposeSymbol} for the * native/fallback resolution rules. */ export declare const asyncDisposeSymbol: unique symbol; /** Object disposable via {@link disposeSymbol}. Mirrors `Disposable` from `esnext.disposable`. */ export interface Disposable { [disposeSymbol](): void; } /** Object disposable via {@link asyncDisposeSymbol}. Mirrors `AsyncDisposable` from `esnext.disposable`. */ export interface AsyncDisposable { [asyncDisposeSymbol](): PromiseLike; } /** * Mirrors the `DisposableStack` interface from `esnext.disposable`, declared * locally so consumers don't need that lib in their TypeScript config. */ export interface DisposableStack { readonly disposed: boolean; dispose(): void; use(value: T): T; adopt(value: T, onDispose: (value: T) => void): T; defer(onDispose: () => void): void; move(): DisposableStack; [disposeSymbol](): void; } export interface DisposableStackConstructor { new (): DisposableStack; readonly prototype: DisposableStack; } /** * Mirrors the `AsyncDisposableStack` interface from `esnext.disposable`, declared * locally so consumers don't need that lib in their TypeScript config. */ export interface AsyncDisposableStack { readonly disposed: boolean; disposeAsync(): Promise; use(value: T): T; adopt(value: T, onDisposeAsync: (value: T) => PromiseLike | void): T; defer(onDisposeAsync: () => PromiseLike | void): void; move(): AsyncDisposableStack; [asyncDisposeSymbol](): Promise; } export interface AsyncDisposableStackConstructor { new (): AsyncDisposableStack; readonly prototype: AsyncDisposableStack; } /** * Spec-compliant `DisposableStack`. Prefers the platform's native class when * present; falls back to a minimal built-in implementation otherwise. */ export declare const DisposableStack: DisposableStackConstructor; /** * Spec-compliant `AsyncDisposableStack`. Prefers the platform's native class * when present; falls back to a minimal built-in implementation otherwise. */ export declare const AsyncDisposableStack: AsyncDisposableStackConstructor; /** * Unwraps a `SuppressedError` chain (as produced by `DisposableStack.dispose()` * when multiple disposers throw) into a flat list, outermost failure first. * Returns `[error]` unchanged if it isn't a `SuppressedError`. */ export declare function unwrapSuppressedErrors(error: unknown): unknown[];