14
14
15
15
// This sample is TypeScript ported version of https://github.com/firebase/quickstart-js.
16
16
17
- /// <reference path="../../../node_modules/firebase/app.d.ts" />
18
- /// <reference path="../../../node_modules/firebase/firebase.d.ts" />
19
-
20
17
import * as firebase from 'firebase' ;
21
18
22
19
const config = {
23
20
apiKey : "<apiKey>" ,
24
21
authDomain : "<domain>" ,
25
22
databaseURL : "<database URL>" ,
26
- storageBucket : "<storage bucket>"
23
+ storageBucket : "<storage bucket>" ,
27
24
} ;
28
25
29
26
firebase . initializeApp ( config ) ;
@@ -34,10 +31,10 @@ function toggleSignIn() {
34
31
if ( firebase . auth ( ) . currentUser ) {
35
32
firebase . auth ( ) . signOut ( ) ;
36
33
} else {
37
- const email = ( < HTMLInputElement > document . getElementById ( 'email' ) ) . value ;
34
+ const email = ( document . getElementById ( 'email' ) as HTMLInputElement ) . value ;
38
35
const password = ( < HTMLInputElement > document . getElementById ( 'password' ) ) . value ;
39
36
firebase . auth ( ) . createUserWithEmailAndPassword ( email , password )
40
- . catch ( ( e ) => {
37
+ . catch ( ( e : firebase . FirebaseError ) => {
41
38
const code = e . code ;
42
39
const message = e . message ;
43
40
@@ -67,7 +64,7 @@ function handleSignUp() {
67
64
return ;
68
65
}
69
66
firebase . auth ( ) . createUserWithEmailAndPassword ( email , password )
70
- . catch ( ( e ) => {
67
+ . catch ( ( e : firebase . FirebaseError ) => {
71
68
const code = e . code ;
72
69
const message = e . message ;
73
70
switch ( code ) {
@@ -82,4 +79,4 @@ function handleSignUp() {
82
79
} )
83
80
} ;
84
81
85
- // port initApp()
82
+ // port initApp()
0 commit comments