fix(60223): add Promise.try() to ESNext lib (#60232)

This commit is contained in:
Dirk Luijk
2024-11-05 17:14:02 -08:00
committed by GitHub
parent 80eeb4ec8d
commit 60dd512a83
79 changed files with 1753 additions and 968 deletions
+1
View File
@@ -247,6 +247,7 @@ const libEntries: [string, string][] = [
["esnext.regexp", "lib.es2024.regexp.d.ts"],
["esnext.string", "lib.es2024.string.d.ts"],
["esnext.iterator", "lib.esnext.iterator.d.ts"],
["esnext.promise", "lib.esnext.promise.d.ts"],
["decorators", "lib.decorators.d.ts"],
["decorators.legacy", "lib.decorators.legacy.d.ts"],
];
+1
View File
@@ -5,3 +5,4 @@
/// <reference lib="esnext.collection" />
/// <reference lib="esnext.array" />
/// <reference lib="esnext.iterator" />
/// <reference lib="esnext.promise" />
+16
View File
@@ -0,0 +1,16 @@
interface PromiseConstructor {
/**
* Takes a callback of any kind (returns or throws, synchronously or asynchronously) and wraps its result
* in a Promise.
*
* @param callbackFn A function that is called synchronously. It can do anything: either return
* a value, throw an error, or return a promise.
* @param args Additional arguments, that will be passed to the callback.
*
* @returns A Promise that is:
* - Already fulfilled, if the callback synchronously returns a value.
* - Already rejected, if the callback synchronously throws an error.
* - Asynchronously fulfilled or rejected, if the callback returns a promise.
*/
try<T, U extends unknown[]>(callbackFn: (...args: U) => T | PromiseLike<T>, ...args: U): Promise<Awaited<T>>;
}
+1
View File
@@ -85,6 +85,7 @@
"esnext.collection",
"esnext.array",
"esnext.iterator",
"esnext.promise",
"decorators",
"decorators.legacy",
// Default libraries