Skip to content

Commit

Permalink
fix issue with const type parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
aleclarson committed Nov 12, 2024
1 parent 82ae85f commit a856cad
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/async/all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ import { AggregateError, isArray } from 'radashi'
* ```
* @version 12.1.0
*/
export async function all<const T extends readonly unknown[]>(
export async function all<T extends readonly [unknown, ...unknown[]]>(
input: T,
): Promise<{ -readonly [I in keyof T]: Awaited<T[I]> }>

export async function all<T extends readonly unknown[]>(
input: T,
): Promise<{ -readonly [I in keyof T]: Awaited<T[I]> }>

Expand Down
6 changes: 6 additions & 0 deletions tests/async/all.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ describe('all', () => {
expectTypeOf(result).toEqualTypeOf<[1, 2, 3]>()
})

test('readonly array input with nested object', async () => {
const result = await all([{ a: 1 }, Promise.resolve({ b: 2 })])

expectTypeOf(result).toEqualTypeOf<[{ a: number }, { b: number }]>()
})

test('readonly object input of promises, promise-like objects, and non-promises', async () => {
const result = await all({
a: Promise.resolve(1 as const),
Expand Down

0 comments on commit a856cad

Please sign in to comment.