Zum Inhalt springen

Missing Await (ARCH3029)

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

Key typescript.async.missing-await · Severity warning · Category async

Using a promise-returning call in a boolean/value position (if, assignment, return) without await is a bug: the promise object is always truthy and the real result is never awaited.

async function ensureAccess(userId: string): Promise<void> {
if (hasPermission(userId)) { // promise is always truthy
grant(userId);
}
}
async function ensureAccess(userId: string): Promise<void> {
if (await hasPermission(userId)) {
grant(userId);
}
}

Await the promise-returning call before using its value.