Skip to content

Commit d767363

Browse files
committed
fixup! refactor: stronger typing of inputs
1 parent c12b358 commit d767363

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

projects/testing-library/src/lib/models.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,7 @@ export type AliasedInputs = Record<string, AliasedInput<unknown>>;
8686

8787
export type ComponentInput<T> =
8888
| {
89-
[P in keyof T]?: T[P] extends Signal<infer U>
90-
? U // If the property is a Signal, apply Partial to the inner type
91-
: Partial<T[P]>; // Otherwise, apply Partial to the property itself
89+
[P in keyof T]?: T[P] extends Signal<infer U> ? U : T[P];
9290
}
9391
| AliasedInputs;
9492

projects/testing-library/tests/render.spec.ts

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -559,21 +559,29 @@ describe('inputs and signals', () => {
559559
});
560560

561561
it('should typecheck correctly', async () => {
562-
// @ts-expect-error - myName is a string
563-
await render(InputComponent, {
564-
inputs: {
565-
myName: 123,
562+
// we only want to check the types here
563+
// so we are purposely not calling render
564+
565+
const typeTests = [
566+
() => {
567+
// @ts-expect-error - myName is a string
568+
await render(InputComponent, {
569+
inputs: {
570+
myName: 123,
571+
},
572+
});
566573
},
567-
});
568-
569-
// @ts-expect-error - job is not using aliasedInputWithValue
570-
await render(InputComponent, {
571-
inputs: {
572-
job: 'not used with aliasedInputWithValue',
574+
() => {
575+
// @ts-expect-error - job is not using aliasedInputWithValue
576+
await render(InputComponent, {
577+
inputs: {
578+
job: 'not used with aliasedInputWithValue',
579+
},
580+
});
573581
},
574-
});
582+
];
575583

576584
// add a statement so the test succeeds
577-
expect(true).toBeTruthy();
585+
expect(typeTests).toBeTruthy();
578586
});
579587
});

0 commit comments

Comments
 (0)