Skip to content

Commit b8c9782

Browse files
authored
fix(typings): Remove incorrect firebase.Promise type definition. (#165)
We were defining our own Promise type, but it's not compatible with the normal es2015.promise type definition, which can result in compile errors if you try to use them together.
1 parent bfcd89e commit b8c9782

File tree

2 files changed

+132
-164
lines changed

2 files changed

+132
-164
lines changed

typings/app.d.ts

Lines changed: 66 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -29,53 +29,37 @@ declare namespace firebase {
2929
next (value : V | null ) : any ;
3030
}
3131

32-
class Promise < T > extends Promise_Instance < T > {
33-
static all (values : firebase.Promise < any > [] ) : firebase.Promise < any [] > ;
34-
static reject (error : Error ) : firebase.Promise < any > ;
35-
static resolve < T > (value ? : T ) : firebase.Promise < T > ;
36-
}
37-
class Promise_Instance < T > implements firebase.Thenable < any > {
38-
constructor (resolver : (a : (a : T ) => void , b : (a : Error ) => void ) => any ) ;
39-
catch (onReject ? : (a : Error ) => any ) : firebase.Thenable < any > ;
40-
then (onResolve ? : (a : T ) => any , onReject ? : (a : Error ) => any ) : firebase.Promise < any > ;
41-
}
42-
4332
var SDK_VERSION : string ;
4433

45-
interface Thenable < T > {
46-
catch (onReject ? : (a : Error ) => any ) : any ;
47-
then (onResolve ? : (a : T ) => any , onReject ? : (a : Error ) => any ) : firebase.Thenable < any > ;
48-
}
49-
5034
type Unsubscribe = ( ) => void ;
5135

5236
interface User extends firebase.UserInfo {
53-
delete ( ) : firebase.Promise < any > ;
37+
delete ( ) : Promise < any > ;
5438
emailVerified : boolean ;
55-
getIdToken (forceRefresh ? : boolean ) : firebase.Promise < any > ;
56-
getToken (forceRefresh ? : boolean ) : firebase.Promise < any > ;
39+
getIdToken (forceRefresh ? : boolean ) : Promise < any > ;
40+
getToken (forceRefresh ? : boolean ) : Promise < any > ;
5741
isAnonymous : boolean ;
58-
linkAndRetrieveDataWithCredential (credential : firebase.auth.AuthCredential ) : firebase.Promise < any > ;
59-
linkWithCredential (credential : firebase.auth.AuthCredential ) : firebase.Promise < any > ;
60-
linkWithPhoneNumber (phoneNumber : string , applicationVerifier : firebase.auth.ApplicationVerifier ) : firebase.Promise < any > ;
61-
linkWithPopup (provider : firebase.auth.AuthProvider ) : firebase.Promise < any > ;
62-
linkWithRedirect (provider : firebase.auth.AuthProvider ) : firebase.Promise < any > ;
42+
linkAndRetrieveDataWithCredential (credential : firebase.auth.AuthCredential ) : Promise < any > ;
43+
linkWithCredential (credential : firebase.auth.AuthCredential ) : Promise < any > ;
44+
linkWithPhoneNumber (phoneNumber : string , applicationVerifier : firebase.auth.ApplicationVerifier ) : Promise < any > ;
45+
linkWithPopup (provider : firebase.auth.AuthProvider ) : Promise < any > ;
46+
linkWithRedirect (provider : firebase.auth.AuthProvider ) : Promise < any > ;
6347
phoneNumber : string | null ;
6448
providerData : ( firebase.UserInfo | null ) [] ;
65-
reauthenticateAndRetrieveDataWithCredential (credential : firebase.auth.AuthCredential ) : firebase.Promise < any > ;
66-
reauthenticateWithCredential (credential : firebase.auth.AuthCredential ) : firebase.Promise < any > ;
67-
reauthenticateWithPhoneNumber (phoneNumber : string , applicationVerifier : firebase.auth.ApplicationVerifier ) : firebase.Promise < any > ;
68-
reauthenticateWithPopup (provider : firebase.auth.AuthProvider ) : firebase.Promise < any > ;
69-
reauthenticateWithRedirect (provider : firebase.auth.AuthProvider ) : firebase.Promise < any > ;
49+
reauthenticateAndRetrieveDataWithCredential (credential : firebase.auth.AuthCredential ) : Promise < any > ;
50+
reauthenticateWithCredential (credential : firebase.auth.AuthCredential ) : Promise < any > ;
51+
reauthenticateWithPhoneNumber (phoneNumber : string , applicationVerifier : firebase.auth.ApplicationVerifier ) : Promise < any > ;
52+
reauthenticateWithPopup (provider : firebase.auth.AuthProvider ) : Promise < any > ;
53+
reauthenticateWithRedirect (provider : firebase.auth.AuthProvider ) : Promise < any > ;
7054
refreshToken : string ;
71-
reload ( ) : firebase.Promise < any > ;
72-
sendEmailVerification (actionCodeSettings ? : firebase.auth.ActionCodeSettings | null ) : firebase.Promise < any > ;
55+
reload ( ) : Promise < any > ;
56+
sendEmailVerification (actionCodeSettings ? : firebase.auth.ActionCodeSettings | null ) : Promise < any > ;
7357
toJSON ( ) : Object ;
74-
unlink (providerId : string ) : firebase.Promise < any > ;
75-
updateEmail (newEmail : string ) : firebase.Promise < any > ;
76-
updatePassword (newPassword : string ) : firebase.Promise < any > ;
77-
updatePhoneNumber (phoneCredential : firebase.auth.AuthCredential ) : firebase.Promise < any > ;
78-
updateProfile (profile : { displayName : string | null , photoURL : string | null } ) : firebase.Promise < any > ;
58+
unlink (providerId : string ) : Promise < any > ;
59+
updateEmail (newEmail : string ) : Promise < any > ;
60+
updatePassword (newPassword : string ) : Promise < any > ;
61+
updatePhoneNumber (phoneCredential : firebase.auth.AuthCredential ) : Promise < any > ;
62+
updateProfile (profile : { displayName : string | null , photoURL : string | null } ) : Promise < any > ;
7963
}
8064

8165
interface UserInfo {
@@ -106,7 +90,7 @@ declare namespace firebase.app {
10690
interface App {
10791
auth ( ) : firebase.auth.Auth ;
10892
database ( ) : firebase.database.Database ;
109-
delete ( ) : firebase.Promise < any > ;
93+
delete ( ) : Promise < any > ;
11094
messaging ( ) : firebase.messaging.Messaging ;
11195
name : string ;
11296
options : Object ;
@@ -124,34 +108,34 @@ declare namespace firebase.auth {
124108

125109
interface ApplicationVerifier {
126110
type : string ;
127-
verify ( ) : firebase.Promise < any > ;
111+
verify ( ) : Promise < any > ;
128112
}
129113

130114
interface Auth {
131115
app : firebase.app.App ;
132-
applyActionCode (code : string ) : firebase.Promise < any > ;
133-
checkActionCode (code : string ) : firebase.Promise < any > ;
134-
confirmPasswordReset (code : string , newPassword : string ) : firebase.Promise < any > ;
135-
createUserWithEmailAndPassword (email : string , password : string ) : firebase.Promise < any > ;
116+
applyActionCode (code : string ) : Promise < any > ;
117+
checkActionCode (code : string ) : Promise < any > ;
118+
confirmPasswordReset (code : string , newPassword : string ) : Promise < any > ;
119+
createUserWithEmailAndPassword (email : string , password : string ) : Promise < any > ;
136120
currentUser : firebase.User | null ;
137-
fetchProvidersForEmail (email : string ) : firebase.Promise < any > ;
138-
getRedirectResult ( ) : firebase.Promise < any > ;
121+
fetchProvidersForEmail (email : string ) : Promise < any > ;
122+
getRedirectResult ( ) : Promise < any > ;
139123
languageCode : string | null ;
140124
onAuthStateChanged (nextOrObserver : firebase.Observer < any , any > | ( (a : firebase.User | null ) => any ) , error ? : (a : firebase.auth.Error ) => any , completed ? : firebase.Unsubscribe ) : firebase.Unsubscribe ;
141125
onIdTokenChanged (nextOrObserver : firebase.Observer < any , any > | ( (a : firebase.User | null ) => any ) , error ? : (a : firebase.auth.Error ) => any , completed ? : firebase.Unsubscribe ) : firebase.Unsubscribe ;
142-
sendPasswordResetEmail (email : string , actionCodeSettings ? : firebase.auth.ActionCodeSettings | null ) : firebase.Promise < any > ;
143-
setPersistence (persistence : firebase.auth.Auth.Persistence ) : firebase.Promise < any > ;
144-
signInAndRetrieveDataWithCredential (credential : firebase.auth.AuthCredential ) : firebase.Promise < any > ;
145-
signInAnonymously ( ) : firebase.Promise < any > ;
146-
signInWithCredential (credential : firebase.auth.AuthCredential ) : firebase.Promise < any > ;
147-
signInWithCustomToken (token : string ) : firebase.Promise < any > ;
148-
signInWithEmailAndPassword (email : string , password : string ) : firebase.Promise < any > ;
149-
signInWithPhoneNumber (phoneNumber : string , applicationVerifier : firebase.auth.ApplicationVerifier ) : firebase.Promise < any > ;
150-
signInWithPopup (provider : firebase.auth.AuthProvider ) : firebase.Promise < any > ;
151-
signInWithRedirect (provider : firebase.auth.AuthProvider ) : firebase.Promise < any > ;
152-
signOut ( ) : firebase.Promise < any > ;
126+
sendPasswordResetEmail (email : string , actionCodeSettings ? : firebase.auth.ActionCodeSettings | null ) : Promise < any > ;
127+
setPersistence (persistence : firebase.auth.Auth.Persistence ) : Promise < any > ;
128+
signInAndRetrieveDataWithCredential (credential : firebase.auth.AuthCredential ) : Promise < any > ;
129+
signInAnonymously ( ) : Promise < any > ;
130+
signInWithCredential (credential : firebase.auth.AuthCredential ) : Promise < any > ;
131+
signInWithCustomToken (token : string ) : Promise < any > ;
132+
signInWithEmailAndPassword (email : string , password : string ) : Promise < any > ;
133+
signInWithPhoneNumber (phoneNumber : string , applicationVerifier : firebase.auth.ApplicationVerifier ) : Promise < any > ;
134+
signInWithPopup (provider : firebase.auth.AuthProvider ) : Promise < any > ;
135+
signInWithRedirect (provider : firebase.auth.AuthProvider ) : Promise < any > ;
136+
signOut ( ) : Promise < any > ;
153137
useDeviceLanguage ( ) : any ;
154-
verifyPasswordResetCode (code : string ) : firebase.Promise < any > ;
138+
verifyPasswordResetCode (code : string ) : Promise < any > ;
155139
}
156140

157141
interface AuthCredential {
@@ -163,7 +147,7 @@ declare namespace firebase.auth {
163147
}
164148

165149
interface ConfirmationResult {
166-
confirm (verificationCode : string ) : firebase.Promise < any > ;
150+
confirm (verificationCode : string ) : Promise < any > ;
167151
verificationId : string ;
168152
}
169153

@@ -217,17 +201,17 @@ declare namespace firebase.auth {
217201
class PhoneAuthProvider_Instance implements firebase.auth.AuthProvider {
218202
constructor (auth ? : firebase.auth.Auth | null ) ;
219203
providerId : string ;
220-
verifyPhoneNumber (phoneNumber : string , applicationVerifier : firebase.auth.ApplicationVerifier ) : firebase.Promise < any > ;
204+
verifyPhoneNumber (phoneNumber : string , applicationVerifier : firebase.auth.ApplicationVerifier ) : Promise < any > ;
221205
}
222206

223207
class RecaptchaVerifier extends RecaptchaVerifier_Instance {
224208
}
225209
class RecaptchaVerifier_Instance implements firebase.auth.ApplicationVerifier {
226210
constructor (container : any | string , parameters ? : Object | null , app ? : firebase.app.App | null ) ;
227211
clear ( ) : any ;
228-
render ( ) : firebase.Promise < any > ;
212+
render ( ) : Promise < any > ;
229213
type : string ;
230-
verify ( ) : firebase.Promise < any > ;
214+
verify ( ) : Promise < any > ;
231215
}
232216

233217
class TwitterAuthProvider extends TwitterAuthProvider_Instance {
@@ -276,11 +260,11 @@ declare namespace firebase.database {
276260
}
277261

278262
interface OnDisconnect {
279-
cancel (onComplete ? : (a : Error | null ) => any ) : firebase.Promise < any > ;
280-
remove (onComplete ? : (a : Error | null ) => any ) : firebase.Promise < any > ;
281-
set (value : any , onComplete ? : (a : Error | null ) => any ) : firebase.Promise < any > ;
282-
setWithPriority (value : any , priority : number | string | null , onComplete ? : (a : Error | null ) => any ) : firebase.Promise < any > ;
283-
update (values : Object , onComplete ? : (a : Error | null ) => any ) : firebase.Promise < any > ;
263+
cancel (onComplete ? : (a : Error | null ) => any ) : Promise < any > ;
264+
remove (onComplete ? : (a : Error | null ) => any ) : Promise < any > ;
265+
set (value : any , onComplete ? : (a : Error | null ) => any ) : Promise < any > ;
266+
setWithPriority (value : any , priority : number | string | null , onComplete ? : (a : Error | null ) => any ) : Promise < any > ;
267+
update (values : Object , onComplete ? : (a : Error | null ) => any ) : Promise < any > ;
284268
}
285269

286270
interface Query {
@@ -291,7 +275,7 @@ declare namespace firebase.database {
291275
limitToLast (limit : number ) : firebase.database.Query ;
292276
off (eventType ? : string , callback ? : (a : firebase.database.DataSnapshot , b ? : string | null ) => any , context ? : Object | null ) : any ;
293277
on (eventType : string , callback : (a : firebase.database.DataSnapshot | null , b ? : string ) => any , cancelCallbackOrContext ? : Object | null , context ? : Object | null ) : (a : firebase.database.DataSnapshot | null , b ? : string ) => any ;
294-
once (eventType : string , successCallback ? : (a : firebase.database.DataSnapshot , b ? : string ) => any , failureCallbackOrContext ? : Object | null , context ? : Object | null ) : firebase.Promise < any > ;
278+
once (eventType : string , successCallback ? : (a : firebase.database.DataSnapshot , b ? : string ) => any , failureCallbackOrContext ? : Object | null , context ? : Object | null ) : Promise < any > ;
295279
orderByChild (path : string ) : firebase.database.Query ;
296280
orderByKey ( ) : firebase.database.Query ;
297281
orderByPriority ( ) : firebase.database.Query ;
@@ -309,16 +293,16 @@ declare namespace firebase.database {
309293
parent : firebase.database.Reference | null ;
310294
path : string ;
311295
push (value ? : any , onComplete ? : (a : Error | null ) => any ) : firebase.database.ThenableReference ;
312-
remove (onComplete ? : (a : Error | null ) => any ) : firebase.Promise < any > ;
296+
remove (onComplete ? : (a : Error | null ) => any ) : Promise < any > ;
313297
root : firebase.database.Reference ;
314-
set (value : any , onComplete ? : (a : Error | null ) => any ) : firebase.Promise < any > ;
315-
setPriority (priority : string | number | null , onComplete : (a : Error | null ) => any ) : firebase.Promise < any > ;
316-
setWithPriority (newVal : any , newPriority : string | number | null , onComplete ? : (a : Error | null ) => any ) : firebase.Promise < any > ;
317-
transaction (transactionUpdate : (a : any ) => any , onComplete ? : (a : Error | null , b : boolean , c : firebase.database.DataSnapshot | null ) => any , applyLocally ? : boolean ) : firebase.Promise < any > ;
318-
update (values : Object , onComplete ? : (a : Error | null ) => any ) : firebase.Promise < any > ;
298+
set (value : any , onComplete ? : (a : Error | null ) => any ) : Promise < any > ;
299+
setPriority (priority : string | number | null , onComplete : (a : Error | null ) => any ) : Promise < any > ;
300+
setWithPriority (newVal : any , newPriority : string | number | null , onComplete ? : (a : Error | null ) => any ) : Promise < any > ;
301+
transaction (transactionUpdate : (a : any ) => any , onComplete ? : (a : Error | null , b : boolean , c : firebase.database.DataSnapshot | null ) => any , applyLocally ? : boolean ) : Promise < any > ;
302+
update (values : Object , onComplete ? : (a : Error | null ) => any ) : Promise < any > ;
319303
}
320304

321-
interface ThenableReference extends firebase.database.Reference , firebase.Thenable < any > {
305+
interface ThenableReference extends firebase.database.Reference , PromiseLike < any > {
322306
}
323307

324308
function enableLogging (logger ? : boolean | ( (a : string ) => any ) , persistent ? : boolean ) : any ;
@@ -330,11 +314,11 @@ declare namespace firebase.database.ServerValue {
330314

331315
declare namespace firebase.messaging {
332316
interface Messaging {
333-
deleteToken (token : string ) : firebase.Promise < any > | null ;
334-
getToken ( ) : firebase.Promise < any > | null ;
317+
deleteToken (token : string ) : Promise < any > | null ;
318+
getToken ( ) : Promise < any > | null ;
335319
onMessage (nextOrObserver : firebase.Observer < any , any > | ( (a : Object ) => any ) ) : firebase.Unsubscribe ;
336320
onTokenRefresh (nextOrObserver : firebase.Observer < any , any > | ( (a : Object ) => any ) ) : firebase.Unsubscribe ;
337-
requestPermission ( ) : firebase.Promise < any > | null ;
321+
requestPermission ( ) : Promise < any > | null ;
338322
setBackgroundMessageHandler (callback : (a : Object ) => any ) : any ;
339323
useServiceWorker (registration : any ) : any ;
340324
}
@@ -356,18 +340,18 @@ declare namespace firebase.storage {
356340
interface Reference {
357341
bucket : string ;
358342
child (path : string ) : firebase.storage.Reference ;
359-
delete ( ) : firebase.Promise < any > ;
343+
delete ( ) : Promise < any > ;
360344
fullPath : string ;
361-
getDownloadURL ( ) : firebase.Promise < any > ;
362-
getMetadata ( ) : firebase.Promise < any > ;
345+
getDownloadURL ( ) : Promise < any > ;
346+
getMetadata ( ) : Promise < any > ;
363347
name : string ;
364348
parent : firebase.storage.Reference | null ;
365349
put (data : any | any | any , metadata ? : firebase.storage.UploadMetadata ) : firebase.storage.UploadTask ;
366350
putString (data : string , format ? : firebase.storage.StringFormat , metadata ? : firebase.storage.UploadMetadata ) : firebase.storage.UploadTask ;
367351
root : firebase.storage.Reference ;
368352
storage : firebase.storage.Storage ;
369353
toString ( ) : string ;
370-
updateMetadata (metadata : firebase.storage.SettableMetadata ) : firebase.Promise < any > ;
354+
updateMetadata (metadata : firebase.storage.SettableMetadata ) : Promise < any > ;
371355
}
372356

373357
interface SettableMetadata {
@@ -417,12 +401,12 @@ declare namespace firebase.storage {
417401

418402
interface UploadTask {
419403
cancel ( ) : boolean ;
420-
catch (onRejected : (a : Error ) => any ) : firebase.Promise < any > ;
404+
catch (onRejected : (a : Error ) => any ) : Promise < any > ;
421405
on (event : firebase.storage.TaskEvent , nextOrObserver ? : firebase.Observer < any , any > | null | ( (a : Object ) => any ) , error ? : ( (a : Error ) => any ) | null , complete ? : ( firebase.Unsubscribe ) | null ) : Function ;
422406
pause ( ) : boolean ;
423407
resume ( ) : boolean ;
424408
snapshot : firebase.storage.UploadTaskSnapshot ;
425-
then (onFulfilled ? : ( (a : firebase.storage.UploadTaskSnapshot ) => any ) | null , onRejected ? : ( (a : Error ) => any ) | null ) : firebase.Promise < any > ;
409+
then (onFulfilled ? : ( (a : firebase.storage.UploadTaskSnapshot ) => any ) | null , onRejected ? : ( (a : Error ) => any ) | null ) : Promise < any > ;
426410
}
427411

428412
interface UploadTaskSnapshot {

0 commit comments

Comments
 (0)