universal-model-angular
Version:
Universal model for Angular
14 lines (13 loc) • 1.07 kB
TypeScript
export declare type SubStateFlagWrapper = {
readonly __isSubState__: boolean;
};
declare type AllowedInitialStateProperties<T extends object> = {
[K in keyof T]: K extends '__isSubState__' ? never : T[K];
};
declare type DisallowedInitialStatePropertyValueType = Error | Date | RegExp | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | ArrayBuffer | DataView | Promise<any> | Generator | GeneratorFunction | ProxyConstructor | Intl.Collator | Intl.DateTimeFormat | Intl.NumberFormat | Intl.PluralRules;
declare type AllowedInitialStatePropertyValueType = number | boolean | string | undefined | null | Array<any> | object | Function;
export declare type InitialState<T> = {
[K in keyof T]: T[K] extends DisallowedInitialStatePropertyValueType ? never : T[K] extends AllowedInitialStatePropertyValueType ? T[K] : never;
};
export default function createSubState<T extends InitialState<T>>(initialState: T & AllowedInitialStateProperties<T>): T & SubStateFlagWrapper;
export {};