Skip to content

Commit

Permalink
Better handle array types when unmasking (#12150)
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller authored Nov 20, 2024
1 parent 78137ec commit 9ed1e1e
Show file tree
Hide file tree
Showing 16 changed files with 20 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .api-reports/api-report-cache.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,7 @@ type UnwrapFragmentRefs<TData> = TData extends any ? string extends keyof NonNul
" $fragmentRefs"?: infer FragmentRefs extends object;
} ? Prettify<{
[K in keyof TData as K extends " $fragmentRefs" ? never : K]: UnwrapFragmentRefs<TData[K]>;
} & CombineFragmentRefs<FragmentRefs>> : never : TData extends object ? {
} & CombineFragmentRefs<FragmentRefs>> : never : TData extends Array<infer TItem> ? Array<UnwrapFragmentRefs<TItem>> : TData extends object ? {
[K in keyof TData]: UnwrapFragmentRefs<TData[K]>;
} : TData : never;

Expand Down
2 changes: 1 addition & 1 deletion .api-reports/api-report-core.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2349,7 +2349,7 @@ type UnwrapFragmentRefs<TData> = TData extends any ? string extends keyof NonNul
" $fragmentRefs"?: infer FragmentRefs extends object;
} ? Prettify<{
[K in keyof TData as K extends " $fragmentRefs" ? never : K]: UnwrapFragmentRefs<TData[K]>;
} & CombineFragmentRefs<FragmentRefs>> : never : TData extends object ? {
} & CombineFragmentRefs<FragmentRefs>> : never : TData extends Array<infer TItem> ? Array<UnwrapFragmentRefs<TItem>> : TData extends object ? {
[K in keyof TData]: UnwrapFragmentRefs<TData[K]>;
} : TData : never;

Expand Down
2 changes: 1 addition & 1 deletion .api-reports/api-report-masking.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ type UnwrapFragmentRefs<TData> = TData extends any ? string extends keyof NonNul
" $fragmentRefs"?: infer FragmentRefs extends object;
} ? Prettify<{
[K in keyof TData as K extends " $fragmentRefs" ? never : K]: UnwrapFragmentRefs<TData[K]>;
} & CombineFragmentRefs<FragmentRefs>> : never : TData extends object ? {
} & CombineFragmentRefs<FragmentRefs>> : never : TData extends Array<infer TItem> ? Array<UnwrapFragmentRefs<TItem>> : TData extends object ? {
[K in keyof TData]: UnwrapFragmentRefs<TData[K]>;
} : TData : never;

Expand Down
2 changes: 1 addition & 1 deletion .api-reports/api-report-react.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2145,7 +2145,7 @@ type UnwrapFragmentRefs<TData> = TData extends any ? string extends keyof NonNul
" $fragmentRefs"?: infer FragmentRefs extends object;
} ? Prettify<{
[K in keyof TData as K extends " $fragmentRefs" ? never : K]: UnwrapFragmentRefs<TData[K]>;
} & CombineFragmentRefs<FragmentRefs>> : never : TData extends object ? {
} & CombineFragmentRefs<FragmentRefs>> : never : TData extends Array<infer TItem> ? Array<UnwrapFragmentRefs<TItem>> : TData extends object ? {
[K in keyof TData]: UnwrapFragmentRefs<TData[K]>;
} : TData : never;

Expand Down
2 changes: 1 addition & 1 deletion .api-reports/api-report-react_components.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1878,7 +1878,7 @@ type UnwrapFragmentRefs<TData> = TData extends any ? string extends keyof NonNul
" $fragmentRefs"?: infer FragmentRefs extends object;
} ? Prettify<{
[K in keyof TData as K extends " $fragmentRefs" ? never : K]: UnwrapFragmentRefs<TData[K]>;
} & CombineFragmentRefs<FragmentRefs>> : never : TData extends object ? {
} & CombineFragmentRefs<FragmentRefs>> : never : TData extends Array<infer TItem> ? Array<UnwrapFragmentRefs<TItem>> : TData extends object ? {
[K in keyof TData]: UnwrapFragmentRefs<TData[K]>;
} : TData : never;

Expand Down
2 changes: 1 addition & 1 deletion .api-reports/api-report-react_context.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1798,7 +1798,7 @@ type UnwrapFragmentRefs<TData> = TData extends any ? string extends keyof NonNul
" $fragmentRefs"?: infer FragmentRefs extends object;
} ? Prettify<{
[K in keyof TData as K extends " $fragmentRefs" ? never : K]: UnwrapFragmentRefs<TData[K]>;
} & CombineFragmentRefs<FragmentRefs>> : never : TData extends object ? {
} & CombineFragmentRefs<FragmentRefs>> : never : TData extends Array<infer TItem> ? Array<UnwrapFragmentRefs<TItem>> : TData extends object ? {
[K in keyof TData]: UnwrapFragmentRefs<TData[K]>;
} : TData : never;

Expand Down
2 changes: 1 addition & 1 deletion .api-reports/api-report-react_hoc.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1802,7 +1802,7 @@ type UnwrapFragmentRefs<TData> = TData extends any ? string extends keyof NonNul
" $fragmentRefs"?: infer FragmentRefs extends object;
} ? Prettify<{
[K in keyof TData as K extends " $fragmentRefs" ? never : K]: UnwrapFragmentRefs<TData[K]>;
} & CombineFragmentRefs<FragmentRefs>> : never : TData extends object ? {
} & CombineFragmentRefs<FragmentRefs>> : never : TData extends Array<infer TItem> ? Array<UnwrapFragmentRefs<TItem>> : TData extends object ? {
[K in keyof TData]: UnwrapFragmentRefs<TData[K]>;
} : TData : never;

Expand Down
2 changes: 1 addition & 1 deletion .api-reports/api-report-react_hooks.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1968,7 +1968,7 @@ type UnwrapFragmentRefs<TData> = TData extends any ? string extends keyof NonNul
" $fragmentRefs"?: infer FragmentRefs extends object;
} ? Prettify<{
[K in keyof TData as K extends " $fragmentRefs" ? never : K]: UnwrapFragmentRefs<TData[K]>;
} & CombineFragmentRefs<FragmentRefs>> : never : TData extends object ? {
} & CombineFragmentRefs<FragmentRefs>> : never : TData extends Array<infer TItem> ? Array<UnwrapFragmentRefs<TItem>> : TData extends object ? {
[K in keyof TData]: UnwrapFragmentRefs<TData[K]>;
} : TData : never;

Expand Down
2 changes: 1 addition & 1 deletion .api-reports/api-report-react_internal.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2020,7 +2020,7 @@ type UnwrapFragmentRefs<TData> = TData extends any ? string extends keyof NonNul
" $fragmentRefs"?: infer FragmentRefs extends object;
} ? Prettify<{
[K in keyof TData as K extends " $fragmentRefs" ? never : K]: UnwrapFragmentRefs<TData[K]>;
} & CombineFragmentRefs<FragmentRefs>> : never : TData extends object ? {
} & CombineFragmentRefs<FragmentRefs>> : never : TData extends Array<infer TItem> ? Array<UnwrapFragmentRefs<TItem>> : TData extends object ? {
[K in keyof TData]: UnwrapFragmentRefs<TData[K]>;
} : TData : never;

Expand Down
2 changes: 1 addition & 1 deletion .api-reports/api-report-react_ssr.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1783,7 +1783,7 @@ type UnwrapFragmentRefs<TData> = TData extends any ? string extends keyof NonNul
" $fragmentRefs"?: infer FragmentRefs extends object;
} ? Prettify<{
[K in keyof TData as K extends " $fragmentRefs" ? never : K]: UnwrapFragmentRefs<TData[K]>;
} & CombineFragmentRefs<FragmentRefs>> : never : TData extends object ? {
} & CombineFragmentRefs<FragmentRefs>> : never : TData extends Array<infer TItem> ? Array<UnwrapFragmentRefs<TItem>> : TData extends object ? {
[K in keyof TData]: UnwrapFragmentRefs<TData[K]>;
} : TData : never;

Expand Down
2 changes: 1 addition & 1 deletion .api-reports/api-report-testing.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1834,7 +1834,7 @@ type UnwrapFragmentRefs<TData> = TData extends any ? string extends keyof NonNul
" $fragmentRefs"?: infer FragmentRefs extends object;
} ? Prettify<{
[K in keyof TData as K extends " $fragmentRefs" ? never : K]: UnwrapFragmentRefs<TData[K]>;
} & CombineFragmentRefs<FragmentRefs>> : never : TData extends object ? {
} & CombineFragmentRefs<FragmentRefs>> : never : TData extends Array<infer TItem> ? Array<UnwrapFragmentRefs<TItem>> : TData extends object ? {
[K in keyof TData]: UnwrapFragmentRefs<TData[K]>;
} : TData : never;

Expand Down
2 changes: 1 addition & 1 deletion .api-reports/api-report-testing_core.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1791,7 +1791,7 @@ type UnwrapFragmentRefs<TData> = TData extends any ? string extends keyof NonNul
" $fragmentRefs"?: infer FragmentRefs extends object;
} ? Prettify<{
[K in keyof TData as K extends " $fragmentRefs" ? never : K]: UnwrapFragmentRefs<TData[K]>;
} & CombineFragmentRefs<FragmentRefs>> : never : TData extends object ? {
} & CombineFragmentRefs<FragmentRefs>> : never : TData extends Array<infer TItem> ? Array<UnwrapFragmentRefs<TItem>> : TData extends object ? {
[K in keyof TData]: UnwrapFragmentRefs<TData[K]>;
} : TData : never;

Expand Down
2 changes: 1 addition & 1 deletion .api-reports/api-report-utilities.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2709,7 +2709,7 @@ type UnwrapFragmentRefs<TData> = TData extends any ? string extends keyof NonNul
" $fragmentRefs"?: infer FragmentRefs extends object;
} ? Prettify<{
[K in keyof TData as K extends " $fragmentRefs" ? never : K]: UnwrapFragmentRefs<TData[K]>;
} & CombineFragmentRefs<FragmentRefs>> : never : TData extends object ? {
} & CombineFragmentRefs<FragmentRefs>> : never : TData extends Array<infer TItem> ? Array<UnwrapFragmentRefs<TItem>> : TData extends object ? {
[K in keyof TData]: UnwrapFragmentRefs<TData[K]>;
} : TData : never;

Expand Down
2 changes: 1 addition & 1 deletion .api-reports/api-report.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2814,7 +2814,7 @@ type UnwrapFragmentRefs<TData> = TData extends any ? string extends keyof NonNul
" $fragmentRefs"?: infer FragmentRefs extends object;
} ? Prettify<{
[K in keyof TData as K extends " $fragmentRefs" ? never : K]: UnwrapFragmentRefs<TData[K]>;
} & CombineFragmentRefs<FragmentRefs>> : never : TData extends object ? {
} & CombineFragmentRefs<FragmentRefs>> : never : TData extends Array<infer TItem> ? Array<UnwrapFragmentRefs<TItem>> : TData extends object ? {
[K in keyof TData]: UnwrapFragmentRefs<TData[K]>;
} : TData : never;

Expand Down
5 changes: 5 additions & 0 deletions .changeset/clean-turkeys-kick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@apollo/client": patch
---

Fix issue when using `Unmasked` with older versions of TypeScript when used with array fields.
1 change: 1 addition & 0 deletions src/masking/internal/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export type UnwrapFragmentRefs<TData> =
} & CombineFragmentRefs<FragmentRefs>
>
: never
: TData extends Array<infer TItem> ? Array<UnwrapFragmentRefs<TItem>>
: TData extends object ?
{ [K in keyof TData]: UnwrapFragmentRefs<TData[K]> }
: TData
Expand Down

0 comments on commit 9ed1e1e

Please sign in to comment.