Here's my latest unsuccessful attempt before seeking guidance. Can anyone point out my mistakes? Thank you!
interface Entity {
id: string;
title: string | null;
}
interface AnotherEntity {
id: string;
title: string;
}
type ExcludeNullFields<T> = {
[K in keyof T as T[K] extends string | null ? K : never]: T[K];
};
type TitlelessEntity = ExcludeNullFields<Entity>;
// expected result: { id: string }
type TitledEntity = ExcludeNullFields<AnotherEntity>;
// expected result: { id: string; title: string }