Aller au contenu

Missing Await (ARCH3029)

Ce contenu n’est pas encore disponible dans votre langue.

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.