mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-20 13:45:34 -05:00
Add types for Promise.withResolvers() (#56593)
This commit is contained in:
@@ -221,7 +221,7 @@ const libEntries: [string, string][] = [
|
||||
["esnext.disposable", "lib.esnext.disposable.d.ts"],
|
||||
["esnext.bigint", "lib.es2020.bigint.d.ts"],
|
||||
["esnext.string", "lib.es2022.string.d.ts"],
|
||||
["esnext.promise", "lib.es2021.promise.d.ts"],
|
||||
["esnext.promise", "lib.esnext.promise.d.ts"],
|
||||
["esnext.weakref", "lib.es2021.weakref.d.ts"],
|
||||
["esnext.decorators", "lib.esnext.decorators.d.ts"],
|
||||
["decorators", "lib.decorators.d.ts"],
|
||||
|
||||
1
src/lib/esnext.d.ts
vendored
1
src/lib/esnext.d.ts
vendored
@@ -2,3 +2,4 @@
|
||||
/// <reference lib="esnext.intl" />
|
||||
/// <reference lib="esnext.decorators" />
|
||||
/// <reference lib="esnext.disposable" />
|
||||
/// <reference lib="esnext.promise" />
|
||||
|
||||
17
src/lib/esnext.promise.d.ts
vendored
Normal file
17
src/lib/esnext.promise.d.ts
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
interface PromiseWithResolvers<T> {
|
||||
promise: Promise<T>;
|
||||
resolve: (value: T | PromiseLike<T>) => void;
|
||||
reject: (reason?: any) => void;
|
||||
}
|
||||
|
||||
interface PromiseConstructor {
|
||||
/**
|
||||
* Creates a new Promise and returns it in an object, along with its resolve and reject functions.
|
||||
* @returns An object with the properties `promise`, `resolve`, and `reject`.
|
||||
*
|
||||
* ```ts
|
||||
* const { promise, resolve, reject } = Promise.withResolvers<T>();
|
||||
* ```
|
||||
*/
|
||||
withResolvers<T>(): PromiseWithResolvers<T>;
|
||||
}
|
||||
@@ -71,6 +71,7 @@
|
||||
"esnext.decorators",
|
||||
"esnext.intl",
|
||||
"esnext.disposable",
|
||||
"esnext.promise",
|
||||
"decorators",
|
||||
"decorators.legacy",
|
||||
// Default libraries
|
||||
|
||||
Reference in New Issue
Block a user