I am trying to create a Type that only contains true
fields.
I was able to achieve the wanted behavior with the new satisfies
keyword but I am sure it has to be possible otherwise.
Example working with 'satisfies'
Without the 'satisfies' keyword it just gives me an empty type.
Example without 'satisfied'
Am I missing something here? In my brain it should just work.
type Fields = {
[FieldName: string]: boolean,
}
type GetTrues<T> = {
[K in keyof T as T[K] extends true ? K : never]: T[K]
}
const fields: Fields = {
trueField: true,
falseField: false
};
type myTrueFields = GetTrues<typeof fields> // expected {trueField: true} got {}