I have an interface IFilterSet with nullable fields:
export interface IFilterSet {
filter1?: boolean;
filter2?: boolean;
filter3?: number;
fitler4?: string;
}
I receive another object X, that may contain IFilterSet object among others.
I want to map the IFilterSet properties of object X. First quess would be to make a loop for those properties, but because they are nullable, it won't work, there will be nothing to loop through. Initialiazing an empty IFilterSet would defeat the purpose of those properties being nullable, right?
{}is assignable toIFilterSet. You can check for the presence of a property by callinghasOwnProperty(prop).export interface IFilterSet { filter1: boolean | null; filter2: boolean | null; filter3: number | null; fitler4: string | null;if you want the fields always be there, but have null values, but I like the first version more.IFilterSet? Would it beX.filterSet,X.etc[?], or other way?