UNPKG

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