Skip to content

Files

Latest commit

 

History

History
23 lines (17 loc) · 489 Bytes

no-await-expression-member.md

File metadata and controls

23 lines (17 loc) · 489 Bytes

Pattern: Member access from await expression

Issue: -

Description

Accessing members directly from an await expression requires parentheses, which reduces code readability. Use destructuring or intermediate variables instead.

Examples

Example of incorrect code:

async function bad() {
  const secondElement = (await getArray())[1];
}

Example of correct code:

async function good() {
  const [, secondElement] = await getArray();
}