/** * An object with both synchronous and asynchronous disposal methods. * * The caller owns disposal. In a runtime that supports explicit resource * management, `using resource = value` calls `Symbol.dispose` at scope exit; * `await using resource = value` calls and awaits `Symbol.asyncDispose`. * Choose one form for a resource. The interface itself performs no cleanup. */ export interface DualDisposable extends Disposable, AsyncDisposable { } /** A value that exposes at least one explicit disposal method. */ export type WithDisposal = T & (Disposable | AsyncDisposable | DualDisposable); /** * A Promise that also exposes both disposal methods. * * This type does not guarantee cleanup when the Promise settles. The * implementation defines what disposal releases, and the caller must invoke * the appropriate disposal method or use a supported resource-management scope. * Awaiting the Promise and disposing it are separate operations. */ export interface PromiseWithDisposal extends Promise, DualDisposable { } /** * Adds cancellation metadata to a Promise with explicit disposal methods. * * @template T - The type of the value that the promise resolves to. */ export interface AbortablePromiseWithDisposal extends PromiseWithDisposal { /** * The signal observed by the underlying operation, if one was provided. * Aborting it stops work only if that operation responds to the signal. */ signal: AbortSignal | null; /** * The `AbortController` used to control the abort signal. If the signal was passed in, this will be `null`. */ controller: AbortController | null; } export interface FutureOperation { ( abort: AbortController, disposables: AsyncDisposableStack, ): AsyncGenerator | Generator; } export interface FutureFromOperation { ( abort: AbortController, disposables: AsyncDisposableStack, ): ReturnType> | PromiseLike | T; }