UNPKG

3.89 kBTypeScriptView Raw
1export interface Action {
2 type: string;
3}
4export declare interface TypedAction<T extends string> extends Action {
5 readonly type: T;
6}
7export declare type ActionType<A> = A extends ActionCreator<infer T, infer C> ? ReturnType<C> & {
8 type: T;
9} : never;
10export declare type TypeId<T> = () => T;
11export declare type InitialState<T> = Partial<T> | TypeId<Partial<T>> | void;
12/**
13 * A function that takes an `Action` and a `State`, and returns a `State`.
14 * See `createReducer`.
15 */
16export interface ActionReducer<T, V extends Action = Action> {
17 (state: T | undefined, action: V): T;
18}
19export declare type ActionReducerMap<T, V extends Action = Action> = {
20 [p in keyof T]: ActionReducer<T[p], V>;
21};
22export interface ActionReducerFactory<T, V extends Action = Action> {
23 (reducerMap: ActionReducerMap<T, V>, initialState?: InitialState<T>): ActionReducer<T, V>;
24}
25export declare type MetaReducer<T = any, V extends Action = Action> = (reducer: ActionReducer<T, V>) => ActionReducer<T, V>;
26export interface StoreFeature<T, V extends Action = Action> {
27 key: string;
28 reducers: ActionReducerMap<T, V> | ActionReducer<T, V>;
29 reducerFactory: ActionReducerFactory<T, V>;
30 initialState?: InitialState<T>;
31 metaReducers?: MetaReducer<T, V>[];
32}
33export declare type Selector<T, V> = (state: T) => V;
34/**
35 * @deprecated Selectors with props are deprecated, for more info see {@link https://github.com/ngrx/platform/issues/2980 Github Issue}
36 */
37export declare type SelectorWithProps<State, Props, Result> = (state: State, props: Props) => Result;
38export declare const arraysAreNotAllowedMsg = "arrays are not allowed in action creators";
39declare type ArraysAreNotAllowed = typeof arraysAreNotAllowedMsg;
40export declare const typePropertyIsNotAllowedMsg = "type property is not allowed in action creators";
41declare type TypePropertyIsNotAllowed = typeof typePropertyIsNotAllowedMsg;
42export declare const emptyObjectsAreNotAllowedMsg = "empty objects are not allowed in action creators";
43declare type EmptyObjectsAreNotAllowed = typeof emptyObjectsAreNotAllowedMsg;
44export declare type FunctionIsNotAllowed<T, ErrorMessage extends string> = T extends Function ? ErrorMessage : T;
45/**
46 * A function that returns an object in the shape of the `Action` interface. Configured using `createAction`.
47 */
48export declare type Creator<P extends any[] = any[], R extends object = object> = FunctionWithParametersType<P, R>;
49export declare type NotAllowedCheck<T extends object> = T extends any[] ? ArraysAreNotAllowed : T extends {
50 type: any;
51} ? TypePropertyIsNotAllowed : keyof T extends never ? EmptyObjectsAreNotAllowed : unknown;
52/**
53 * See `Creator`.
54 */
55export declare type ActionCreator<T extends string = string, C extends Creator = Creator> = C & TypedAction<T>;
56export interface ActionCreatorProps<T> {
57 _as: 'props';
58 _p: T;
59}
60export declare type FunctionWithParametersType<P extends unknown[], R = void> = (...args: P) => R;
61export declare type ParametersType<T> = T extends (...args: infer U) => unknown ? U : never;
62export interface RuntimeChecks {
63 /**
64 * Verifies if the state is serializable
65 */
66 strictStateSerializability: boolean;
67 /**
68 * Verifies if the actions are serializable. Please note, you may not need to set it to `true` unless you are storing/replaying actions using external resources, for example `localStorage`.
69 */
70 strictActionSerializability: boolean;
71 /**
72 * Verifies that the state isn't mutated
73 */
74 strictStateImmutability: boolean;
75 /**
76 * Verifies that actions aren't mutated
77 */
78 strictActionImmutability: boolean;
79 /**
80 * Verifies that actions are dispatched within NgZone
81 */
82 strictActionWithinNgZone: boolean;
83 /**
84 * Verifies that action types are not registered more than once
85 */
86 strictActionTypeUniqueness?: boolean;
87}
88export {};