Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit 0af93e1

Browse files
author
jpaagt
committed
Added es6-promise.d.ts
1 parent 241fa01 commit 0af93e1

File tree

2 files changed

+147
-0
lines changed

2 files changed

+147
-0
lines changed

es6-promise.d.ts

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
/* tslint:disable */
2+
// Type definitions for es6-promise
3+
// Project: https://github.com/jakearchibald/ES6-Promise
4+
// Definitions by: François de Campredon <https://github.com/fdecampredon/>
5+
// Definitions: https://github.com/borisyankov/DefinitelyTyped
6+
interface Thenable<R> {
7+
then<U>(onFulfilled?: (value: R) => Thenable<U>, onRejected?: (error: any) => Thenable<U>): Thenable<U>;
8+
then<U>(onFulfilled?: (value: R) => Thenable<U>, onRejected?: (error: any) => U): Thenable<U>;
9+
then<U>(onFulfilled?: (value: R) => Thenable<U>, onRejected?: (error: any) => void): Thenable<U>;
10+
then<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => Thenable<U>): Thenable<U>;
11+
then<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U): Thenable<U>;
12+
then<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => void): Thenable<U>;
13+
}
14+
15+
interface Promise<R> extends Thenable<R> {
16+
/**
17+
* onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects.
18+
* Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called.
19+
* Both callbacks have a single parameter , the fulfillment value or rejection reason.
20+
* "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve.
21+
* If an error is thrown in the callback, the returned promise rejects with that error.
22+
* @param onFulfilled called when/if "promise" resolves
23+
* @param onRejected called when/if "promise" rejects
24+
*/
25+
then<U>(onFulfilled?: (value: R) => Thenable<U>, onRejected?: (error: any) => Thenable<U>): Promise<U>;
26+
/**
27+
* onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects.
28+
* Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called.
29+
* Both callbacks have a single parameter , the fulfillment value or rejection reason.
30+
* "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve.
31+
* If an error is thrown in the callback, the returned promise rejects with that error.
32+
* @param onFulfilled called when/if "promise" resolves
33+
* @param onRejected called when/if "promise" rejects
34+
*/
35+
then<U>(onFulfilled?: (value: R) => Thenable<U>, onRejected?: (error: any) => U): Promise<U>;
36+
/**
37+
* onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects.
38+
* Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called.
39+
* Both callbacks have a single parameter , the fulfillment value or rejection reason.
40+
* "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve.
41+
* If an error is thrown in the callback, the returned promise rejects with that error.
42+
* @param onFulfilled called when/if "promise" resolves
43+
* @param onRejected called when/if "promise" rejects
44+
*/
45+
then<U>(onFulfilled?: (value: R) => Thenable<U>, onRejected?: (error: any) => void): Promise<U>;
46+
/**
47+
* onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects.
48+
* Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called.
49+
* Both callbacks have a single parameter , the fulfillment value or rejection reason.
50+
* "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve.
51+
* If an error is thrown in the callback, the returned promise rejects with that error.
52+
* @param onFulfilled called when/if "promise" resolves
53+
* @param onRejected called when/if "promise" rejects
54+
*/
55+
then<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => Thenable<U>): Promise<U>;
56+
/**
57+
* onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects.
58+
* Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called.
59+
* Both callbacks have a single parameter , the fulfillment value or rejection reason.
60+
* "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve.
61+
* If an error is thrown in the callback, the returned promise rejects with that error.
62+
* @param onFulfilled called when/if "promise" resolves
63+
* @param onRejected called when/if "promise" rejects
64+
*/
65+
then<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U): Promise<U>;
66+
/**
67+
* onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects.
68+
* Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called.
69+
* Both callbacks have a single parameter , the fulfillment value or rejection reason.
70+
* "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve.
71+
* If an error is thrown in the callback, the returned promise rejects with that error.
72+
* @param onFulfilled called when/if "promise" resolves
73+
* @param onRejected called when/if "promise" rejects
74+
*/
75+
then<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => void): Promise<U>;
76+
77+
/**
78+
* Sugar for promise.then(undefined, onRejected)
79+
* @param onRejected called when/if "promise" rejects
80+
*/
81+
catch<U>(onRejected?: (error: any) => Thenable<U>): Promise<U>;
82+
/**
83+
* Sugar for promise.then(undefined, onRejected)
84+
* @param onRejected called when/if "promise" rejects
85+
*/
86+
catch<U>(onRejected?: (error: any) => U): Promise<U>;
87+
/**
88+
* Sugar for promise.then(undefined, onRejected)
89+
* @param onRejected called when/if "promise" rejects
90+
*/
91+
catch<U>(onRejected?: (error: any) => void): Promise<U>;
92+
}
93+
94+
interface PromiseConstructor {
95+
/**
96+
* A reference to the prototype.
97+
*/
98+
prototype: Promise<any>;
99+
100+
/**
101+
* Creates a new Promise.
102+
* @param executor A callback used to initialize the promise. This callback is passed two arguments:
103+
* a resolve callback used resolve the promise with a value or the result of another promise,
104+
* and a reject callback used to reject the promise with a provided reason or error.
105+
*/
106+
new <T>(executor: (resolve: (value?: T | Thenable<T>) => void, reject: (reason?: any) => void) => void): Promise<T>;
107+
108+
/**
109+
* Returns promise (only if promise.constructor == Promise)
110+
*/
111+
cast<R>(promise: Promise<R>): Promise<R>;
112+
/**
113+
* Make a promise that fulfills to obj.
114+
*/
115+
cast<R>(object: R): Promise<R>;
116+
117+
/**
118+
* Make a new promise from the thenable.
119+
* A thenable is promise-like in as far as it has a "then" method.
120+
* This also creates a new promise if you pass it a genuine JavaScript promise, making it less efficient for casting than Promise.cast.
121+
*/
122+
resolve<R>(thenable?: Thenable<R>): Promise<R>;
123+
/**
124+
* Make a promise that fulfills to obj. Same as Promise.cast(obj) in this situation.
125+
*/
126+
resolve<R>(object?: R): Promise<R>;
127+
128+
/**
129+
* Make a promise that rejects to obj. For consistency and debugging (eg stack traces), obj should be an instanceof Error
130+
*/
131+
reject(error: any): Promise<any>;
132+
133+
/**
134+
* Make a promise that fulfills when every item in the array fulfills, and rejects if (and when) any item rejects.
135+
* the array passed to all can be a mixture of promise-like objects and other objects.
136+
* The fulfillment value is an array (in order) of fulfillment values. The rejection value is the first rejection value.
137+
*/
138+
all<R>(promises: Promise<R>[]): Promise<R[]>;
139+
140+
/**
141+
* Make a Promise that fulfills when any item fulfills, and rejects if any item rejects.
142+
*/
143+
race<R>(promises: Promise<R>[]): Promise<R>;
144+
}
145+
146+
declare var Promise: PromiseConstructor;

firebase.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/// <reference path="firebase-common.d.ts"/>
2+
/// <reference path="es6-promise.d.ts"/>
23
declare module "nativescript-plugin-firebase" {
34

45
/**

0 commit comments

Comments
 (0)