小编jbo*_*boo的帖子

createUserWithEmailAndPassword 和使用 firebase.auth.Error 处理 catch 给出编译错误 TS2345

当我调用以下方法并想捕获错误并检查错误代码时,我无法指定错误类型以外的错误类型,因此无法访问错误。代码来自firebase.auth.Error.

方法描述:(方法)firebase.auth.Auth.createUserWithEmailAndPassword(email: string, password: string): firebase.Promise

Specifingfirebase.auth.Auth在当时的工作,但firebase.auth.Error给我一个编译错误。

error TS2345: Argument of type '(error: Error) => void' is not assignable to parameter of type '(a: Error) => any'.
Types of parameters 'error' and 'a' are incompatible.
Type 'Error' is not assignable to type 'firebase.auth.Error'.
Property 'code' is missing in type 'Error'.
Run Code Online (Sandbox Code Playgroud)

 

this.auth.createUserWithEmailAndPassword(username, password)
                .then( (auth: firebase.auth.Auth) => { return auth; } )
                .catch( (error: firebase.auth.Error) => {

                    let errorCode = error.code;
                    let errorMessage = error.message; …
Run Code Online (Sandbox Code Playgroud)

firebase typescript firebase-authentication

1
推荐指数
1
解决办法
3056
查看次数