我想在TypeScript函数内部调用JavaScript函数并返回一个布尔值,如以下示例所示:
public authenticate(username: string, password: string): boolean {
return this._client.bind(username, password, (err, obj) => {
if (err) {
return false;
} else {
return true;
}
});
}
TypeScript给我以下错误:
TS2355: A function whose declared type is neither 'void' nor 'any' must return a value.
如何避免此错误?