-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpromise.d.ts
60 lines (56 loc) · 2.11 KB
/
promise.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
interface PromiseLike<T> {
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
*
* @param onfulfilled - The callback to execute when the Promise is
* resolved.
* @param onrejected - The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
*/
then(
onfulfilled?: undefined,
onrejected?: (reason: unknown) => PromiseLike<T> | T,
): PromiseLike<T>;
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
*
* @param onfulfilled - The callback to execute when the Promise is
* resolved.
* @param onrejected - The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
*/
then<U>(
onfulfilled: (value: T) => PromiseLike<U> | U,
onrejected?: (reason: unknown) => PromiseLike<U> | U,
): PromiseLike<U>;
}
interface Promise<T> extends PromiseLike<T> {
/**
* Attaches a callback for only the rejection of the Promise.
*
* @param onrejected - The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of the callback.
*/
catch(onrejected?: (reason: unknown) => PromiseLike<T> | T): Promise<T>;
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
*
* @param onfulfilled - The callback to execute when the Promise is
* resolved.
* @param onrejected - The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
*/
then(onfulfilled?: undefined, onrejected?: (reason: unknown) => PromiseLike<T> | T): Promise<T>;
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
*
* @param onfulfilled - The callback to execute when the Promise is
* resolved.
* @param onrejected - The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
*/
then<U>(
onfulfilled: (value: T) => PromiseLike<U> | U,
onrejected?: (reason: unknown) => PromiseLike<U> | U,
): Promise<U>;
}