|
| 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 |
| 6 | +
|
| 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. |
| 11 | +
|
| 12 | +See the Apache Version 2.0 License for specific language governing permissions |
| 13 | +and limitations under the License. |
| 14 | +***************************************************************************** */ |
| 15 | + |
| 16 | + |
| 17 | +/// <reference no-default-lib="true"/> |
| 18 | + |
| 19 | +interface PromiseConstructor { |
| 20 | + /** |
| 21 | + * A reference to the prototype. |
| 22 | + */ |
| 23 | + readonly prototype: Promise<any>; |
| 24 | + |
| 25 | + /** |
| 26 | + * Creates a new Promise. |
| 27 | + * @param executor A callback used to initialize the promise. This callback is passed two arguments: |
| 28 | + * a resolve callback used to resolve the promise with a value or the result of another promise, |
| 29 | + * and a reject callback used to reject the promise with a provided reason or error. |
| 30 | + */ |
| 31 | + new <T>(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void): Promise<T>; |
| 32 | + |
| 33 | + /** |
| 34 | + * Creates a Promise that is resolved with an array of results when all of the provided Promises |
| 35 | + * resolve, or rejected when any Promise is rejected. |
| 36 | + * @param values An array of Promises. |
| 37 | + * @returns A new Promise. |
| 38 | + */ |
| 39 | + all<T extends readonly unknown[] | []>(values: T): Promise<{ -readonly [P in keyof T]: Awaited<T[P]>; }>; |
| 40 | + |
| 41 | + // see: lib.es2015.iterable.d.ts |
| 42 | + // all<T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>[]>; |
| 43 | + |
| 44 | + /** |
| 45 | + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved |
| 46 | + * or rejected. |
| 47 | + * @param values An array of Promises. |
| 48 | + * @returns A new Promise. |
| 49 | + */ |
| 50 | + race<T extends readonly unknown[] | []>(values: T): Promise<Awaited<T[number]>>; |
| 51 | + |
| 52 | + // see: lib.es2015.iterable.d.ts |
| 53 | + // race<T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>>; |
| 54 | + |
| 55 | + /** |
| 56 | + * Creates a new rejected promise for the provided reason. |
| 57 | + * @param reason The reason the promise was rejected. |
| 58 | + * @returns A new rejected Promise. |
| 59 | + */ |
| 60 | + reject<T = never>(reason?: any): Promise<T>; |
| 61 | + |
| 62 | + /** |
| 63 | + * Creates a new resolved promise. |
| 64 | + * @returns A resolved promise. |
| 65 | + */ |
| 66 | + resolve(): Promise<void>; |
| 67 | + /** |
| 68 | + * Creates a new resolved promise for the provided value. |
| 69 | + * @param value A promise. |
| 70 | + * @returns A promise whose internal state matches the provided promise. |
| 71 | + */ |
| 72 | + resolve<T>(value: T): Promise<Awaited<T>>; |
| 73 | + /** |
| 74 | + * Creates a new resolved promise for the provided value. |
| 75 | + * @param value A promise. |
| 76 | + * @returns A promise whose internal state matches the provided promise. |
| 77 | + */ |
| 78 | + resolve<T>(value: T | PromiseLike<T>): Promise<Awaited<T>>; |
| 79 | +} |
| 80 | + |
| 81 | +declare var Promise: PromiseConstructor; |
0 commit comments