From a856cad1c8c9946e511c54cd309535c3af6763a5 Mon Sep 17 00:00:00 2001 From: Alec Larson <1925840+aleclarson@users.noreply.github.com> Date: Tue, 12 Nov 2024 12:04:20 -0500 Subject: [PATCH] fix issue with `const` type parameter --- src/async/all.ts | 6 +++++- tests/async/all.test-d.ts | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/async/all.ts b/src/async/all.ts index 7c9eea07..58df015f 100644 --- a/src/async/all.ts +++ b/src/async/all.ts @@ -15,7 +15,11 @@ import { AggregateError, isArray } from 'radashi' * ``` * @version 12.1.0 */ -export async function all( +export async function all( + input: T, +): Promise<{ -readonly [I in keyof T]: Awaited }> + +export async function all( input: T, ): Promise<{ -readonly [I in keyof T]: Awaited }> diff --git a/tests/async/all.test-d.ts b/tests/async/all.test-d.ts index ea038841..e762f699 100644 --- a/tests/async/all.test-d.ts +++ b/tests/async/all.test-d.ts @@ -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),