结果已声明,但其值永远不会在离子3上读取

问题描述 投票:2回答:1

我有以下代码

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();
javascript angular typescript ionic3
1个回答
2
投票

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

要禁用该规则(来自tslint),您可以更新它:

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

© www.soinside.com 2019 - 2024. All rights reserved.