Skip to content

Commit

Permalink
Ensure tuple types are left unchanged
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller committed Dec 9, 2024
1 parent 3eb9696 commit 821b9b4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
18 changes: 18 additions & 0 deletions src/masking/__benches__/types.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -480,3 +480,21 @@ test("does not detect `$fragmentRefs` if type contains `any`", (prefix) => {
expectTypeOf(x).branded.toEqualTypeOf<Source>();
});
});

test("leaves tuples alone", (prefix) => {
interface Source {
coords: [long: number, lat: number];
}

bench(prefix + "instantiations", () => {
return {} as Unmasked<Source>;
}).types([5, "instantiations"]);

bench(prefix + "functionality", () => {
const x = {} as Unmasked<Source>;

expectTypeOf(x).branded.toEqualTypeOf<{
coords: [long: number, lat: number];
}>();
});
});
1 change: 0 additions & 1 deletion src/masking/internal/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export type UnwrapFragmentRefs<TData> =
>
>
>
: TData extends Array<infer TItem> ? Array<UnwrapFragmentRefs<TItem>>
: TData extends object ?
{
[K in keyof TData]: UnwrapFragmentRefs<TData[K]>;
Expand Down

0 comments on commit 821b9b4

Please sign in to comment.