Is there a way to create a customized type by extracting specific properties from a generic type?
class Test {
value1!: Date
value2!: number
value3!: Date
value4!: string
}
type FilterProperties<T, TFieldType> = //looking for a solution to select fields of the type TFieldType only
const onlyDates = {} as FilterProperties<Test, Date>
FilterProperties<Test, Date>
should ideally contain only the properties value1
and value3
.
I attempted using Extract
and Pick
, but they operate based on keys rather than types.