Files
simply_cpq/website/node_modules/@mui/x-internals/disposable/index.d.mts
T
2026-08-07 21:39:30 +02:00

74 lines
3.0 KiB
TypeScript

/**
* 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<void>;
}
/**
* 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<T extends Disposable | null | undefined>(value: T): T;
adopt<T>(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<void>;
use<T extends AsyncDisposable | Disposable | null | undefined>(value: T): T;
adopt<T>(value: T, onDisposeAsync: (value: T) => PromiseLike<void> | void): T;
defer(onDisposeAsync: () => PromiseLike<void> | void): void;
move(): AsyncDisposableStack;
[asyncDisposeSymbol](): Promise<void>;
}
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[];