fix: deepkeyandvalue behavior in union types #2057
Openmdm317(GitHub profile, opens in a new tab)wants to merge 8 commits into
main fromrefs/pull/2057/headopened - @@ -194,3 +196,7 @@194196 TFieldGroupData[K]195197 >196198 }199+200+type ExtractByNonNullableValue<T, TValue> = T extends { value: infer V }201+ ? [NonNullable<V>] extends [never]202+ ? never@@ -194,3 +196,14 @@194196 TFieldGroupData[K]195197 >196198 }199+200+type ExtractByNonNullableValue<T, TValue> = T extends { value: infer V }201+ ? [NonNullable<V>] extends [never]202+ ? never203+ : NonNullable<V> extends TValue204+ ? T205+ : never206+ : never207+208+export type DeepKeysOfNonNullableType<TData, TValue> =209+ ExtractByNonNullableValue<DeepKeysAndValues<TData>, TValue>['key']
LeCarbonator(GitHub profile, opens in a new tab) requested changes
@@ -149,4 +138,17 @@149- ? TAcc | UnknownDeepKeyAndValue<TParent>150- : T extends object151- ? DeepKeyAndValueObject<TParent, T, TAcc>152- : TAcc138+> = [T] extends [never]139+ ? TAcc140+ : unknown extends T141+ ? TAcc | UnknownDeepKeyAndValue<TParent>142+ : unknown extends T // this stops runaway recursion when T is any143+ ? T144+ : T extends string | number | boolean | bigint | Date145+ ? TAcc146+ : T extends ReadonlyArray<any>147+ ? number extends T['length']148+ ? DeepKeyAndValueArray<TParent, T, TAcc>149+ : DeepKeyAndValueTuple<TParent, T, TAcc>150+ : keyof T extends never151+ ? TAcc | UnknownDeepKeyAndValue<TParent>152+ : T extends object153+ ? DeepKeyAndValueObject<TParent, T, TAcc>154+ : TAcc- @@ -91,4 +91,4 @@9191 TFormData,9292 TFieldGroupData,9393 TFields extends94- | DeepKeysOfType<TFormData, TFieldGroupData | null | undefined>94+ | DeepKeysOfNonNullableType<TFormData, TFieldGroupData>
mdm317(GitHub profile, opens in a new tab) linked this to fix #1813
Sign in to join this conversation.
🦋 Changeset detected#
Latest commit: 81806f87eb0be16c246e1ba0e1301d1851306f4f
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 13 packages
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