# no-await-in-promise-methods

Disallow awaiting elements passed to Promise concurrency methods

Awaiting a Promise inside the input array delays every following element and can serialize their operations.
Instead, you SHOULD pass each Promise directly so `Promise.all` or `Promise.race` can observe them together.

- Category: performance
- Level: warning
- Fix: suggestion
- Scope: module

## Reported

```ds title="main.ds"
import { Promise } from "destack:async";

declare function first(): Promise<int32>;
declare function second(): Promise<int32>;

async function gather(): Promise<int32[]> {
    return await Promise.all([await first(), second()]);
}
```

## Accepted

```ds title="main.ds"
import { Promise } from "destack:async";

declare function first(): Promise<int32>;
declare function second(): Promise<int32>;

async function gather(): Promise<int32[]> {
    return await Promise.all([first(), second()]);
}
```

## Prior art

- [eslint-plugin-unicorn · no-await-in-promise-methods](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-await-in-promise-methods.md)

[language/linter/src/rules/performance/no_await_in_promise_methods.rs:8](https://github.com/destack-sh/destack/blob/main/language/linter/src/rules/performance/no_await_in_promise_methods.rs#L8)
