无法解决/拒绝 Promise

Cannot resolve / reject a Promise

我写了一个 service 方法,它允许 user 在我的 restify API 中获得身份验证。 get 方法调用这个:

public async auth(email: string, password: string): Promise<Customer> {
    let connection = await DatabaseProvider.getConnection();
    const customer = await connection.getRepository(Customer).findOne({ email });

    try {
        let isMatch = await bcrypt.compare(password, customer!.password);

        if (!isMatch) throw 'Password did not match';
        Promise.resolve(customer);
    } catch (err) {
        Promise.reject('Authentication failed');
    }
}

我遇到的问题是:

A function whose declared type is neither 'void' nor 'any' must return a value.

似乎 Promise.resolve(customer) 没有 return 任何东西,我也尝试用 return 作为前缀,但同样的问题

public async auth(email: string, password: string): Promise<Customer> {
    let connection = await DatabaseProvider.getConnection();

    const customer = await connection.getRepository(Customer).findOne({ email });

    let isMatch = await bcrypt.compare(password, customer!.password);

    if (!isMatch) throw 'Password did not match';

    if(customer)
      return customer;

    throw 'Customer is undefined';
}

我想这应该有用...