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
Combining PartialDeep with a generic does not accept an empty object initializer:
importtype{PartialDeep,UnknownRecord}from'type-fest';typePerson={name: string;age: number;};constmock=<TextendsUnknownRecord>(mock: PartialDeep<T>={}): T=>mockasT;// ~~~~~~~~~~~~~~~~~~~~~~~~~//=> Error (ts2322): Type `{}` is not assignable to type `PartialDeep<T>`constperson=mock<Person>({name: 'Bob'});// ^? const person: Person
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:
Just my own opinion, it probably has nothing to do with PartialDeep, A simpler example is:
// Type 'string' is not assignable to type 'T'.// 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string'.(2322)constfunc=<Textendsstring>(value: T='')=>value;
Because T can be any subtype of UnknownRecord, it could even be never; And if T is never, then mock: PartialDeep<T> is never, in this case {} cannot be assigned to never, so TS made such a complaint.
In addition, the following code is error-free:
importtype{PartialDeep,UnknownRecord}from'type-fest';// no error here, so "{} is assignable to type PartialDeep<T>"constfoo: PartialDeep<UnknownRecord>={};
Combining
PartialDeep
with a generic does not accept an empty object initializer:Upvote & Fund
The text was updated successfully, but these errors were encountered: