I generated the following code snippet:
type NumberFields<T, K extends keyof T> = T[K] extends number ? K : never;
type AnsFields<T> = SomeOtherList & NumberFields<T, keyof T>;
In the code above, SomeOtherList consists of predefined field names such as 'foo' | 'bar'
.
Although the type definition is functioning correctly, I am interested in utilizing only AnsFields<T>
. Is there a way to combine the definitions of NumberFields
and AnsFields
into a single instance? Thus far, I have not been able to find a solution.