You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying out remeda and came around the MergeDeep type when using the mergeDeep function from remeda.
My problem is that the MergeDeep type always uses the property type of the source value instead of using the value of the destination incase the source value is undefined.
import{MergeDeep}from'type-fest';typePerson={name: string;age: number};typePartialPerson=Partial<Person>;// type of MergeDeepPersonPartialFirst makes sense, since all Person values will be usedtypeMergeDeepPersonPartialFirst=MergeDeep<PartialPerson,Person>;// I assumed this would be inferred as the same type as MergeDeepPersonPartialLast// but it gets infered as// {// name?: string | undefined;// age?: number | undefined;// }typeMergeDeepPersonPartialLast=MergeDeep<Person,PartialPerson>;constperson: Person={name: 'a',age: 25};constpartialPerson: PartialPerson={name: 'b'};// both values get inferred as// {// name: string;// age: number;// }// equivalent to PersonconstspreadPartialLast={ ...person, ...partialPerson};constspreadPartiaFirst={ ...partialPerson, ...person};// on a sideonde// these get infered as stringtypetest1=string&(string|undefined);typetest2=(string|undefined)&string;// these get infered as something equivalent to Persontypetest3=Partial<Person>&Person;typetest4=Person&Partial<Person>;
Thanks for the your time
Upvote & Fund
We're using Polar.sh so you can upvote and help fund this issue.
The funding will be given to active contributors.
Thank you in advance for helping prioritize & fund our backlog.
The text was updated successfully, but these errors were encountered:
I am trying out remeda and came around the MergeDeep type when using the mergeDeep function from remeda.
My problem is that the MergeDeep type always uses the property type of the source value instead of using the value of the destination incase the source value is undefined.
Does this work as intended or is this a bug?
stackblitz
Thanks for the your time
Upvote & Fund
The text was updated successfully, but these errors were encountered: