1 /*! *****************************************************************************
2 Copyright (c) Microsoft Corporation. All rights reserved.
3 Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4 this file except in compliance with the License. You may obtain a copy of the
5 License at http://www.apache.org/licenses/LICENSE-2.0
7 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8 KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
9 WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
10 MERCHANTABLITY OR NON-INFRINGEMENT.
12 See the Apache Version 2.0 License for specific language governing permissions
13 and limitations under the License.
14 ***************************************************************************** */
18 /// <reference no-default-lib="true"/>
\r
21 interface PromiseConstructor {
\r
23 * A reference to the prototype.
\r
25 readonly prototype: Promise<any>;
\r
28 * Creates a new Promise.
\r
29 * @param executor A callback used to initialize the promise. This callback is passed two arguments:
\r
30 * a resolve callback used to resolve the promise with a value or the result of another promise,
\r
31 * and a reject callback used to reject the promise with a provided reason or error.
\r
33 new <T>(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void): Promise<T>;
\r
36 * Creates a Promise that is resolved with an array of results when all of the provided Promises
\r
37 * resolve, or rejected when any Promise is rejected.
\r
38 * @param values An array of Promises.
\r
39 * @returns A new Promise.
\r
41 all<T extends readonly unknown[] | []>(values: T): Promise<{ -readonly [P in keyof T]: Awaited<T[P]> }>;
\r
43 // see: lib.es2015.iterable.d.ts
\r
44 // all<T>(values: Iterable<T | PromiseLike<T>>): Promise<T[]>;
\r
47 * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
\r
49 * @param values An array of Promises.
\r
50 * @returns A new Promise.
\r
52 race<T extends readonly unknown[] | []>(values: T): Promise<Awaited<T[number]>>;
\r
54 // see: lib.es2015.iterable.d.ts
\r
55 // race<T>(values: Iterable<T>): Promise<T extends PromiseLike<infer U> ? U : T>;
\r
58 * Creates a new rejected promise for the provided reason.
\r
59 * @param reason The reason the promise was rejected.
\r
60 * @returns A new rejected Promise.
\r
62 reject<T = never>(reason?: any): Promise<T>;
\r
65 * Creates a new resolved promise.
\r
66 * @returns A resolved promise.
\r
68 resolve(): Promise<void>;
\r
71 * Creates a new resolved promise for the provided value.
\r
72 * @param value A promise.
\r
73 * @returns A promise whose internal state matches the provided promise.
\r
75 resolve<T>(value: T | PromiseLike<T>): Promise<T>;
\r
78 declare var Promise: PromiseConstructor;
\r