-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Data masking] Ensure null
is retained when unmasking nullable objects
#12133
Conversation
✅ Docs Preview ReadyNo new or changed pages found. |
🦋 Changeset detectedLatest commit: 07b38d5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
src/masking/internal/types.ts
Outdated
} & CombineFragmentRefs<FragmentRefs> | ||
> | ||
: never | ||
null extends TData ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't let me apply a suggestion here, but as an alternative, you could also distribute over TData
:
This is the change to the original type:
export type UnwrapFragmentRefs<TData> =
+ TData extends any ?
// Leave TData alone if it is Record<string, any> and not a specific shape
string extends keyof NonNullable<TData> ? TData
: " $fragmentRefs" extends keyof NonNullable<TData> ?
TData extends { " $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 ?
{ [K in keyof TData]: UnwrapFragmentRefs<TData[K]> }
: TData
+ : never;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes I like that much better! Updated in ba2cb2c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either way, this fixes a real bug - approved :)
94e0f01
to
f30d83c
Compare
c02a3ab
to
07b38d5
Compare
size-limit report 📦
|
The
Unmasked
helper has a bug where unmasking a nullable object would return the object as a non-null type. This PR ensures thenull
is retained in the type.