We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 40caf34 commit dbb3235Copy full SHA for dbb3235
src/lib/es2024.promise.d.ts
@@ -14,4 +14,18 @@ interface PromiseConstructor {
14
* ```
15
*/
16
withResolvers<T>(): PromiseWithResolvers<T>;
17
+
18
+ /**
19
+ * Takes a callback of any kind (returns or throws, synchronously or asynchronously) and wraps its result
20
+ * in a Promise.
21
+ *
22
+ * @param callbackFn A function that is called synchronously with no arguments. It can do anything: either return
23
+ * a value, throw an error, or return a promise.
24
25
+ * @returns A Promise that is:
26
+ * - Already fulfilled, if callbackFn synchronously returns a value.
27
+ * - Already rejected, if callbackFn synchronously throws an error.
28
+ * - Asynchronously fulfilled or rejected, if callbackFn returns a promise.
29
+ */
30
+ try<T>(callbackFn: () => T | Promise<T>): Promise<T>;
31
}
0 commit comments