reactish-state 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reactish-state",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "",
5
5
  "author": "Zheng Song",
6
6
  "license": "MIT",
@@ -1,22 +1,22 @@
1
1
  declare type Listener = () => void;
2
2
  declare type Setter<T> = (newValue: T | ((value: T) => T)) => void;
3
- declare type ActionCreator<T, A> = (set: Setter<T>, get: () => T) => A;
3
+ declare type ActionCreator<T, A> = ((set: Setter<T>, get: () => T) => A) | undefined;
4
4
  interface Reactish<T> {
5
5
  get: () => T;
6
6
  subscribe: (listener: Listener) => () => void;
7
7
  }
8
- interface State<T, A = unknown> extends Reactish<T> {
8
+ interface State<T, A = unknown, C extends ActionCreator<T, A> = undefined> extends Reactish<T> {
9
9
  set: Setter<T>;
10
- actions?: A;
10
+ actions: C extends undefined ? never : A;
11
11
  }
12
- declare const state: <T, A>(initialValue: T, actionCreator?: ActionCreator<T, A>) => State<T, A>;
12
+ declare const state: <T, A>(initialValue: T, actionCreator?: ActionCreator<T, A>) => State<T, A, ActionCreator<T, A>>;
13
13
  declare type ReactishArray = Reactish<unknown>[];
14
14
  declare type ReactishValueArray<R extends ReactishArray> = {
15
15
  [index in keyof R]: ReturnType<R[index]['get']>;
16
16
  };
17
- declare type SelectorFunc<R extends ReactishArray, V> = (...args: ReactishValueArray<R>) => V;
18
- declare const selector: <R extends ReactishArray, V>(...items: [...R, SelectorFunc<R, V>]) => {
19
- get: () => V;
17
+ declare type SelectorFunc<R extends ReactishArray, T> = (...args: ReactishValueArray<R>) => T;
18
+ declare const selector: <R extends ReactishArray, T>(...items: [...R, SelectorFunc<R, T>]) => {
19
+ get: () => T;
20
20
  subscribe: (listener: Listener) => () => void;
21
21
  };
22
22
  export { Reactish, state, selector };