【问题标题】:Result is declared but its value is never read on ionic 3结果已声明,但从未在 ionic 3 上读取其值
【发布时间】:2019-02-08 22:14:12
【问题描述】:

我有以下代码

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();

【问题讨论】:

  • 我认为这是在抱怨您没有对 result 变量做任何事情。尝试只做await this.afAuth.auth.createUserWithEmailAndPassword(user.email, user.password);。听起来像是 linter 错误而不是编译器错误
  • 谢谢!请将您的回答作为问题,以便我将问题标记为已解决!

标签: javascript angular typescript ionic3


【解决方案1】:

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

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-08-10
    • 2018-09-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-27
    • 2019-01-06
    相关资源
    最近更新 更多