interface Foo {
name: string;
}
function make<TModel extends Record<string, any>, TDefaultFields extends [keyof TModel] | undefined = undefined>(options?: {
defaultFields?: TDefaultFields
}) {
return function<TDefaultFields>(): Pick<TModel, TDefaultFields> {}
}
const fn = make<Foo>({
defaultFields: ['foo']
})
const x = fn();
The code above is a stripped out version of what I want to reach eventually, essentially I want to create a factory function that will be able to return a subset of TModel yet I cannot event get over the first hurdle being the inference of TDefaultFields