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