声明了结果,但从未在ionic 3上读取其值

时间:2018-09-03 22:35:30

标签: javascript angular typescript ionic3

我有以下代码

async register(user: User){
try {
  const result = await this.afAuth.auth.createUserWithEmailAndPassword(user.email, user.password);
  this.userRegister();
}
catch {
  this.showAlert();
}

}

但是当我运行命令ionic build --release --prod时,终端会告诉我以下消息

  tslint: C:/Users/Mike/Desktop/GuiaCorretor/src/pages/register/register.ts, line: 39
      'result' is declared but its value is never read.

    try {
      const result = await this.afAuth.auth.createUserWithEmailAndPassword(user.email, user.password);
      this.userRegister();

1 个答案:

答案 0 :(得分:2)

我认为这是在抱怨您对结果变量没有做任何事情。尝试做 改为await this.afAuth.auth.createUserWithEmailAndPassword(user.email, user.password);。听起来像是linter错误,而不是编译器错误

要禁用规则(来自tslint),可以对其进行更新:

https://palantir.github.io/tslint/rules/no-unused-variable/