From de1e83de866a174a004f1236b3b8a06497b624ee Mon Sep 17 00:00:00 2001 From: Kai Ninomiya Date: Wed, 25 Oct 2023 16:28:46 -0700 Subject: [PATCH] nits --- src/common/framework/params_builder.ts | 7 +++++-- src/common/internal/test_group.ts | 8 +++++--- src/common/util/types.ts | 6 +++++- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/common/framework/params_builder.ts b/src/common/framework/params_builder.ts index 5124b7a8c68e..845d1cd2e92a 100644 --- a/src/common/framework/params_builder.ts +++ b/src/common/framework/params_builder.ts @@ -156,7 +156,7 @@ export class CaseParamsBuilder } } - yield [caseP as DeepReadonly, undefined]; + yield [caseP as DeepReadonly, undefined]; } } @@ -303,7 +303,10 @@ export class SubcaseParamsBuilder const subcases = Array.from(this.subcases(caseP)); if (subcases.length) { - yield [caseP as DeepReadonly, subcases as DeepReadonly[]]; + yield [ + caseP as DeepReadonly, + subcases as DeepReadonly[], + ]; } } } diff --git a/src/common/internal/test_group.ts b/src/common/internal/test_group.ts index 92560e55aae0..6e13fbf47458 100644 --- a/src/common/internal/test_group.ts +++ b/src/common/internal/test_group.ts @@ -83,9 +83,11 @@ export function makeTestGroupForUnitTesting( /** Parameter name for batch number (see also TestBuilder.batch). */ const kBatchParamName = 'batch__'; -type TestFn = (t: F & { params: P }) => Promise | void; +type TestFn = ( + t: F & { params: DeepReadonly

} +) => Promise | void; type BeforeAllSubcasesFn = ( - s: S & { params: P } + s: S & { params: DeepReadonly

} ) => Promise | void; export class TestGroup implements TestGroupBuilder { @@ -217,7 +219,7 @@ interface TestBuilderWithParams>>): void; + fn(fn: TestFn>): void; /** * Mark the test as unimplemented. */ diff --git a/src/common/util/types.ts b/src/common/util/types.ts index 4f01a016ed34..5714df73f00b 100644 --- a/src/common/util/types.ts +++ b/src/common/util/types.ts @@ -13,7 +13,10 @@ export type TypeEqual = (() => T extends X ? 1 : 2) extends () => T /* eslint-disable-next-line @typescript-eslint/no-unused-vars */ export function assertTypeTrue() {} -export type Primitive = string | number | boolean | undefined | null | Function | symbol; +/** + * Deep version of the Readonly<> type, with support for tuples (up to length 7). + * + */ export type DeepReadonly = T extends [infer A] ? DeepReadonlyObject<[A]> : T extends [infer A, infer B] @@ -40,6 +43,7 @@ export type DeepReadonly = T extends [infer A] ? DeepReadonlyArray : DeepReadonlyObject; +type Primitive = string | number | boolean | undefined | null | Function | symbol; type DeepReadonlyArray = ReadonlyArray>; type DeepReadonlyObject = { readonly [P in keyof T]: DeepReadonly };