Partial Interfaces Example
type NestedProperty = {
foo: string;
bar: string;
};
interface ComponentOptions {
foobar: NestedProperty;
foobaz: boolean;
}
const DEFAULT_OPTIONS: ComponentOptions = {
foobar: {
foo: "foo",
bar: "bar",
},
foobaz: false,
};
const Component = (options: Partial<ComponentOptions>): ComponentOptions => {
const mergedOptions = Object.assign({}, DEFAULT_OPTIONS, options);
return mergedOptions;
};
Component({
foobaz: true,
});
thanks i would try it out