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<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>, T10 | PromiseLike<T10>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; 42 43 /** 44 * Creates a Promise that is resolved with an array of results when all of the provided Promises 45 * resolve, or rejected when any Promise is rejected. 46 * @param values An array of Promises. 47 * @returns A new Promise. 48 */ 49 all<T1, T2, T3, T4, T5, T6, T7, T8, T9>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; 50 51 /** 52 * Creates a Promise that is resolved with an array of results when all of the provided Promises 53 * resolve, or rejected when any Promise is rejected. 54 * @param values An array of Promises. 55 * @returns A new Promise. 56 */ 57 all<T1, T2, T3, T4, T5, T6, T7, T8>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; 58 59 /** 60 * Creates a Promise that is resolved with an array of results when all of the provided Promises 61 * resolve, or rejected when any Promise is rejected. 62 * @param values An array of Promises. 63 * @returns A new Promise. 64 */ 65 all<T1, T2, T3, T4, T5, T6, T7>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; 66 67 /** 68 * Creates a Promise that is resolved with an array of results when all of the provided Promises 69 * resolve, or rejected when any Promise is rejected. 70 * @param values An array of Promises. 71 * @returns A new Promise. 72 */ 73 all<T1, T2, T3, T4, T5, T6>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>]): Promise<[T1, T2, T3, T4, T5, T6]>; 74 75 /** 76 * Creates a Promise that is resolved with an array of results when all of the provided Promises 77 * resolve, or rejected when any Promise is rejected. 78 * @param values An array of Promises. 79 * @returns A new Promise. 80 */ 81 all<T1, T2, T3, T4, T5>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>]): Promise<[T1, T2, T3, T4, T5]>; 82 83 /** 84 * Creates a Promise that is resolved with an array of results when all of the provided Promises 85 * resolve, or rejected when any Promise is rejected. 86 * @param values An array of Promises. 87 * @returns A new Promise. 88 */ 89 all<T1, T2, T3, T4>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>]): Promise<[T1, T2, T3, T4]>; 90 91 /** 92 * Creates a Promise that is resolved with an array of results when all of the provided Promises 93 * resolve, or rejected when any Promise is rejected. 94 * @param values An array of Promises. 95 * @returns A new Promise. 96 */ 97 all<T1, T2, T3>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>]): Promise<[T1, T2, T3]>; 98 99 /** 100 * Creates a Promise that is resolved with an array of results when all of the provided Promises 101 * resolve, or rejected when any Promise is rejected. 102 * @param values An array of Promises. 103 * @returns A new Promise. 104 */ 105 all<T1, T2>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<[T1, T2]>; 106 107 /** 108 * Creates a Promise that is resolved with an array of results when all of the provided Promises 109 * resolve, or rejected when any Promise is rejected. 110 * @param values An array of Promises. 111 * @returns A new Promise. 112 */ 113 all<T>(values: (T | PromiseLike<T>)[]): Promise<T[]>; 114 115 /** 116 * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved 117 * or rejected. 118 * @param values An array of Promises. 119 * @returns A new Promise. 120 */ 121 race<T>(values: T[]): Promise<T extends PromiseLike<infer U> ? U : T>; 122 123 /** 124 * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved 125 * or rejected. 126 * @param values An iterable of Promises. 127 * @returns A new Promise. 128 */ 129 race<T>(values: Iterable<T>): Promise<T extends PromiseLike<infer U> ? U : T>; 130 131 /** 132 * Creates a new rejected promise for the provided reason. 133 * @param reason The reason the promise was rejected. 134 * @returns A new rejected Promise. 135 */ 136 reject<T = never>(reason?: any): Promise<T>; 137 138 /** 139 * Creates a new resolved promise for the provided value. 140 * @param value A promise. 141 * @returns A promise whose internal state matches the provided promise. 142 */ 143 resolve<T>(value: T | PromiseLike<T>): Promise<T>; 144 145 /** 146 * Creates a new resolved promise . 147 * @returns A resolved promise. 148 */ 149 resolve(): Promise<void>; 150} 151 152declare var Promise: PromiseConstructor; 153