UNPKG

5.09 kBTypeScriptView Raw
1import { type ValueEqualityFn } from '@angular/core';
2export interface Action {
3 type: string;
4}
5export declare interface TypedAction<T extends string> extends Action {
6 readonly type: T;
7}
8export type ActionType<A> = A extends ActionCreator<infer T, infer C> ? ReturnType<C> & {
9 type: T;
10} : never;
11export type TypeId<T> = () => T;
12export type InitialState<T> = Partial<T> | TypeId<Partial<T>> | void;
13/**
14 * A function that takes an `Action` and a `State`, and returns a `State`.
15 * See `createReducer`.
16 */
17export interface ActionReducer<T, V extends Action = Action> {
18 (state: T | undefined, action: V): T;
19}
20export type ActionReducerMap<T, V extends Action = Action> = {
21 [p in keyof T]: ActionReducer<T[p], V>;
22};
23export interface ActionReducerFactory<T, V extends Action = Action> {
24 (reducerMap: ActionReducerMap<T, V>, initialState?: InitialState<T>): ActionReducer<T, V>;
25}
26export type MetaReducer<T = any, V extends Action = Action> = (reducer: ActionReducer<T, V>) => ActionReducer<T, V>;
27export interface StoreFeature<T, V extends Action = Action> {
28 key: string;
29 reducers: ActionReducerMap<T, V> | ActionReducer<T, V>;
30 reducerFactory: ActionReducerFactory<T, V>;
31 initialState?: InitialState<T>;
32 metaReducers?: MetaReducer<T, V>[];
33}
34export type Selector<T, V> = (state: T) => V;
35/**
36 * @deprecated Selectors with props are deprecated, for more info see {@link https://github.com/ngrx/platform/issues/2980 Github Issue}
37 */
38export type SelectorWithProps<State, Props, Result> = (state: State, props: Props) => Result;
39export declare const arraysAreNotAllowedMsg = "action creator cannot return an array";
40type ArraysAreNotAllowed = typeof arraysAreNotAllowedMsg;
41export declare const typePropertyIsNotAllowedMsg = "action creator cannot return an object with a property named `type`";
42type TypePropertyIsNotAllowed = typeof typePropertyIsNotAllowedMsg;
43export declare const emptyObjectsAreNotAllowedMsg = "action creator cannot return an empty object";
44type EmptyObjectsAreNotAllowed = typeof emptyObjectsAreNotAllowedMsg;
45export declare const arraysAreNotAllowedInProps = "action creator props cannot be an array";
46type ArraysAreNotAllowedInProps = typeof arraysAreNotAllowedInProps;
47export declare const typePropertyIsNotAllowedInProps = "action creator props cannot have a property named `type`";
48type TypePropertyIsNotAllowedInProps = typeof typePropertyIsNotAllowedInProps;
49export declare const emptyObjectsAreNotAllowedInProps = "action creator props cannot be an empty object";
50type EmptyObjectsAreNotAllowedInProps = typeof emptyObjectsAreNotAllowedInProps;
51export declare const primitivesAreNotAllowedInProps = "action creator props cannot be a primitive value";
52type PrimitivesAreNotAllowedInProps = typeof primitivesAreNotAllowedInProps;
53export type FunctionIsNotAllowed<T, ErrorMessage extends string> = T extends Function ? ErrorMessage : T;
54/**
55 * A function that returns an object in the shape of the `Action` interface. Configured using `createAction`.
56 */
57export type Creator<P extends any[] = any[], R extends object = object> = FunctionWithParametersType<P, R>;
58export type Primitive = string | number | bigint | boolean | symbol | null | undefined;
59export type NotAllowedCheck<T extends object> = T extends any[] ? ArraysAreNotAllowed : T extends {
60 type: any;
61} ? TypePropertyIsNotAllowed : keyof T extends never ? EmptyObjectsAreNotAllowed : unknown;
62export type NotAllowedInPropsCheck<T> = T extends object ? T extends any[] ? ArraysAreNotAllowedInProps : T extends {
63 type: any;
64} ? TypePropertyIsNotAllowedInProps : keyof T extends never ? EmptyObjectsAreNotAllowedInProps : unknown : T extends Primitive ? PrimitivesAreNotAllowedInProps : never;
65/**
66 * See `Creator`.
67 */
68export type ActionCreator<T extends string = string, C extends Creator = Creator> = C & TypedAction<T>;
69export interface ActionCreatorProps<T> {
70 _as: 'props';
71 _p: T;
72}
73export type FunctionWithParametersType<P extends unknown[], R = void> = (...args: P) => R;
74export interface RuntimeChecks {
75 /**
76 * Verifies if the state is serializable
77 */
78 strictStateSerializability: boolean;
79 /**
80 * 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`.
81 */
82 strictActionSerializability: boolean;
83 /**
84 * Verifies that the state isn't mutated
85 */
86 strictStateImmutability: boolean;
87 /**
88 * Verifies that actions aren't mutated
89 */
90 strictActionImmutability: boolean;
91 /**
92 * Verifies that actions are dispatched within NgZone
93 */
94 strictActionWithinNgZone: boolean;
95 /**
96 * Verifies that action types are not registered more than once
97 */
98 strictActionTypeUniqueness?: boolean;
99}
100export interface SelectSignalOptions<T> {
101 /**
102 * A comparison function which defines equality for select results.
103 */
104 equal?: ValueEqualityFn<T>;
105}
106export type Prettify<T> = {
107 [K in keyof T]: T[K];
108} & {};
109export {};