Combining PartialDeep
with a generic does not accept an empty object initializer:
import type {PartialDeep, UnknownRecord} from 'type-fest';
type Person = {
name: string;
age: number;
};
const mock = <T extends UnknownRecord>(mock: PartialDeep<T> = {}): T => mock as T;
// ~~~~~~~~~~~~~~~~~~~~~~~~~
//=> Error (ts2322): Type `{}` is not assignable to type `PartialDeep<T>`
const person = mock<Person>({name: 'Bob'});
// ^? const person: Person
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too