import { Observable } from "rxjs"; export const DEFAULT_OPTIONS = { shouldUpdate: () => true, combineLatestWith: null as Observable, msTimeout: 1000, }; type DefinitelyTypedDefault = Omit< typeof DEFAULT_OPTIONS, "shouldUpdate" | "combineLatestWith" > & { shouldUpdate: (state: T, dependency: TCombine) => boolean; combineLatestWith?: Observable; }; export type StateUpdateOptions = Partial>; export function populateOptionsWithDefault( options: StateUpdateOptions ): StateUpdateOptions { return { ...(DEFAULT_OPTIONS as StateUpdateOptions), ...options, }; }