Unnecessary Async Await (ARCH3025)
Esta página aún no está disponible en tu idioma.
Key typescript.async.unnecessary-async-await · Severity info · Category async
An async function whose only await is on the single returned expression adds a state-machine/microtask hop with no benefit. The promise can be returned directly.
Incorrect
Section titled “Incorrect”async function getUser(id: string): Promise<User> { return await db.users.findById(id);}Correct
Section titled “Correct”function getUser(id: string): Promise<User> { return db.users.findById(id);}Drop the async/await pair and return the promise directly; keep the await only if it is inside a try/catch.