-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Open
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug
Description
⚙ Compilation target
esnext
⚙ Library
lib.esnext.disposable.d.ts
Missing / Incorrect Definition
AyncDisposable doe not allow for a non-Promise returning implementation.
Current:
interface AsyncDisposable {
[Symbol.asyncDispose](): PromiseLike<void>;
}Suggested:
interface AsyncDisposable {
[Symbol.asyncDispose](): void | PromiseLike<void>;
}Sample Code
// valid:
await using disposableAsync = { async [Symbol.asyncDispose]() {} };
// valid but flagged by TS as invalid:
await using disposable = { [Symbol.asyncDispose]() {} };
// The initializer of an 'await using' declaration must be either an object with a '[Symbol.asyncDispose]()' or '[Symbol.dispose]()' method, or be 'null' or 'undefined'.
// Type '{ [Symbol.asyncDispose](): void; }' is not assignable to type 'AsyncDisposable'.
// The types returned by '[Symbol.asyncDispose]()' are incompatible between these types.
// Type 'void' is not assignable to type 'PromiseLike<void>'.Documentation Link
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug