From 1c3fe7fbe92ccb58d2d27e8ba2003e28e7ebad68 Mon Sep 17 00:00:00 2001 From: Arabinda Date: Tue, 24 Dec 2024 04:07:45 +0530 Subject: [PATCH 01/28] create zustand-x new version --- package.json | 6 +- packages/zustand-x/src/createStore.ts | 159 +- .../src/middlewares/immer.middleware.ts | 20 - packages/zustand-x/src/middlewares/index.ts | 5 - packages/zustand-x/src/types.ts | 7 - .../zustand-x/src/types/CreateStoreOptions.ts | 27 - packages/zustand-x/src/types/ImmerOptions.ts | 7 - .../zustand-x/src/types/PersistOptions.ts | 14 - packages/zustand-x/src/types/index.ts | 7 - packages/zustand-x/src/utils/extendActions.ts | 8 - .../zustand-x/src/utils/extendSelectors.ts | 52 +- .../src/utils/generateStateActions.ts | 22 +- .../src/utils/generateStateGetSelectors.ts | 11 +- .../src/utils/generateStateHookSelectors.ts | 29 +- .../generateStateTrackedHooksSelectors.ts | 10 +- packages/zustand-x/src/utils/mapValuesKey.ts | 23 - packages/zustand-x/src/utils/pipe.ts | 4247 ----------------- packages/zustand-x/src/utils/types.v2.ts | 115 + yarn.lock | 30 +- 19 files changed, 271 insertions(+), 4528 deletions(-) delete mode 100644 packages/zustand-x/src/middlewares/immer.middleware.ts delete mode 100644 packages/zustand-x/src/middlewares/index.ts delete mode 100644 packages/zustand-x/src/types/CreateStoreOptions.ts delete mode 100644 packages/zustand-x/src/types/ImmerOptions.ts delete mode 100644 packages/zustand-x/src/types/PersistOptions.ts delete mode 100644 packages/zustand-x/src/types/index.ts delete mode 100644 packages/zustand-x/src/utils/pipe.ts create mode 100644 packages/zustand-x/src/utils/types.v2.ts diff --git a/package.json b/package.json index 2cc2e58..abfa03c 100644 --- a/package.json +++ b/package.json @@ -102,13 +102,15 @@ "turbo": "^1.11.0", "turbowatch": "2.29.4", "typedoc": "^0.25.4", - "typescript": "5.3.3", - "zustand": "^4.4.7" + "typescript": "5.3.3" }, "packageManager": "yarn@4.0.2", "engines": { "node": ">=18.12.0", "yarn": ">=1.22.0", "npm": "please-use-yarn" + }, + "dependencies": { + "zustand": "5.0.2" } } diff --git a/packages/zustand-x/src/createStore.ts b/packages/zustand-x/src/createStore.ts index 111ea1f..cdd7982 100644 --- a/packages/zustand-x/src/createStore.ts +++ b/packages/zustand-x/src/createStore.ts @@ -1,99 +1,84 @@ -import { enableMapSet, setAutoFreeze } from 'immer'; import { createTrackedSelector } from 'react-tracked'; +import { createStore as createStoreZustand } from 'zustand'; import { - devtools as devtoolsMiddleware, + devtools as devToolsMiddleware, + DevtoolsOptions, persist as persistMiddleware, + PersistOptions, } from 'zustand/middleware'; import { useStoreWithEqualityFn } from 'zustand/traditional'; -import { createStore as createVanillaStore } from 'zustand/vanilla'; -import { immerMiddleware } from './middlewares/immer.middleware'; -import { - ImmerStoreApi, - MergeState, - SetImmerState, - State, - StateActions, - StateGetters, - StoreApi, - UseImmerStore, -} from './types'; -import { CreateStoreOptions } from './types/CreateStoreOptions'; +import { extendSelectors } from './utils'; import { generateStateActions } from './utils/generateStateActions'; import { generateStateGetSelectors } from './utils/generateStateGetSelectors'; import { generateStateHookSelectors } from './utils/generateStateHookSelectors'; import { generateStateTrackedHooksSelectors } from './utils/generateStateTrackedHooksSelectors'; -import { pipe } from './utils/pipe'; -import { storeFactory } from './utils/storeFactory'; - -import type { StateCreator } from 'zustand'; - +import { + TEqualityChecker, + TStateActions, + TStateApi, + TStoreMiddlewareCreatorType, + TStoreSelectorType, +} from './utils/types.v2'; + +import type { StateCreator, StoreMutatorIdentifier } from 'zustand'; + +type TCreateStoreOptions = { + persist?: Partial> & { + enabled?: boolean; + }; + devtools?: Partial & { + enabled?: boolean; + }; +}; export const createStore = (name: TName) => - ( - initialState: T, - options: CreateStoreOptions = {} - ): StoreApi> => { - const { - middlewares: _middlewares = [], - devtools, - persist, - immer, - } = options; - - setAutoFreeze(immer?.enabledAutoFreeze ?? false); - if (immer?.enableMapSet) { - enableMapSet(); - } - - const middlewares: any[] = [immerMiddleware, ..._middlewares]; - - if (persist?.enabled) { - const opts = { - ...persist, - name: persist.name ?? name, - }; - - middlewares.push((config: any) => persistMiddleware(config, opts)); - } + < + StateType, + Mps extends [StoreMutatorIdentifier, unknown][] = [], + Mcs extends [StoreMutatorIdentifier, unknown][] = [], + >( + createState: StateCreator, + options: TCreateStoreOptions = {} + ) => { + const { devtools, persist } = options; + + const middlewares: (( + initializer: StateCreator + ) => StateCreator)[] = []; if (devtools?.enabled) { - middlewares.push((config: any) => - devtoolsMiddleware(config, { ...devtools, name }) + middlewares.push((config) => + devToolsMiddleware(config, { ...devtools, name }) ); } - middlewares.push(createVanillaStore); + if (persist?.enabled) { + middlewares.push((config) => + persistMiddleware(config, { + ...persist, + name: persist.name ?? name, + }) + ); + } - // @ts-ignore - const pipeMiddlewares = (createState: StateCreator>) => - pipe(createState as any, ...middlewares) as ImmerStoreApi; + const stateMutators = middlewares.reduce( + (y: any, fn) => fn(y), + createState + ) as TStoreMiddlewareCreatorType; - const store = pipeMiddlewares(() => initialState); - const useStore = ((selector, equalityFn) => - useStoreWithEqualityFn( - store as any, - selector as any, - equalityFn as any - )) as UseImmerStore; + const store = createStoreZustand(stateMutators); - const stateActions = generateStateActions(store, name); + const getterSelectors = generateStateGetSelectors(store); - const mergeState: MergeState = (state, actionName) => { - store.setState( - (draft) => { - Object.assign(draft as any, state); - }, - actionName || `@@${name}/mergeState` - ); - }; + const useStore = ( + selector: TStoreSelectorType, + equalityFn?: TEqualityChecker + ): FilteredStateType => useStoreWithEqualityFn(store, selector, equalityFn); - const setState: SetImmerState = (fn, actionName) => { - store.setState(fn, actionName || `@@${name}/setState`); - }; + const stateActions = generateStateActions(store, name); const hookSelectors = generateStateHookSelectors(useStore, store); - const getterSelectors = generateStateGetSelectors(store); const useTrackedStore = createTrackedSelector(useStore); const trackedHooksSelectors = generateStateTrackedHooksSelectors( @@ -101,28 +86,40 @@ export const createStore = store ); - const api = { + const apiInternal: TStateApi> = { + getInitialState: store.getInitialState, get: { state: store.getState, ...getterSelectors, - } as StateGetters, + }, name, set: { - state: setState, - mergeState, + state: store.setState, ...stateActions, - } as StateActions, + }, store, + useStore, use: hookSelectors, useTracked: trackedHooksSelectors, - useStore, useTrackedStore, - extendSelectors: () => api as any, - extendActions: () => api as any, + extendSelectors: () => apiInternal as any, + extendActions: () => apiInternal as any, }; - return storeFactory(api) as StoreApi>; + const storeFactory = ( + api: TStateApi> + ) => { + return { + ...api, + extendSelectors: (builder) => + storeFactory(extendSelectors(builder, api)), + } as TStateApi>; + }; + + return storeFactory(apiInternal); }; +// const a = createStore("a")(()=>({vv:""})) + // Alias {@link createStore} export const createZustandStore = createStore; diff --git a/packages/zustand-x/src/middlewares/immer.middleware.ts b/packages/zustand-x/src/middlewares/immer.middleware.ts deleted file mode 100644 index 1c63905..0000000 --- a/packages/zustand-x/src/middlewares/immer.middleware.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { produce } from 'immer'; -import { StoreApi } from 'zustand'; - -import { SetImmerState, State, StateCreatorWithDevtools } from '../types'; - -export const immerMiddleware = - ( - config: StateCreatorWithDevtools< - T, - SetImmerState, - StoreApi['getState'] - > - ): StateCreatorWithDevtools => - (set, get, api) => { - const setState: SetImmerState = (fn, actionName) => - set(produce(fn), true, actionName); - api.setState = setState as any; - - return config(setState, get, api); - }; diff --git a/packages/zustand-x/src/middlewares/index.ts b/packages/zustand-x/src/middlewares/index.ts deleted file mode 100644 index 5cc309c..0000000 --- a/packages/zustand-x/src/middlewares/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -/** - * @file Automatically generated by barrelsby. - */ - -export * from './immer.middleware'; diff --git a/packages/zustand-x/src/types.ts b/packages/zustand-x/src/types.ts index 6fbaac1..a5d505e 100644 --- a/packages/zustand-x/src/types.ts +++ b/packages/zustand-x/src/types.ts @@ -126,13 +126,6 @@ export interface UseImmerStore setState: SetImmerState; } -export type GetRecord = { - [K in keyof O]: (equalityFn?: EqualityChecker) => O[K]; -}; -export type SetRecord = { - [K in keyof O]: (value: O[K]) => void; -}; - // export type UseRecord = { // [K in keyof O as `use${Capitalize}`]: () => O[K]; // }; diff --git a/packages/zustand-x/src/types/CreateStoreOptions.ts b/packages/zustand-x/src/types/CreateStoreOptions.ts deleted file mode 100644 index a19fe5e..0000000 --- a/packages/zustand-x/src/types/CreateStoreOptions.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { DevtoolsOptions } from 'zustand/middleware'; - -import { State } from '../types'; -import { ImmerOptions } from './ImmerOptions'; -import { PersistOptions } from './PersistOptions'; - -export interface CreateStoreOptions { - /** - * Zustand middlewares. - */ - middlewares?: any[]; - - /** - * Devtools middleware options. - */ - devtools?: DevtoolsOptions; - - /** - * Immer middleware options. - */ - immer?: ImmerOptions; - - /** - * Persist middleware options. - */ - persist?: PersistOptions>; -} diff --git a/packages/zustand-x/src/types/ImmerOptions.ts b/packages/zustand-x/src/types/ImmerOptions.ts deleted file mode 100644 index 8ec8d72..0000000 --- a/packages/zustand-x/src/types/ImmerOptions.ts +++ /dev/null @@ -1,7 +0,0 @@ -export interface ImmerOptions { - /** - * Enable autofreeze. - */ - enabledAutoFreeze?: boolean; - enableMapSet?: boolean; -} diff --git a/packages/zustand-x/src/types/PersistOptions.ts b/packages/zustand-x/src/types/PersistOptions.ts deleted file mode 100644 index b8370be..0000000 --- a/packages/zustand-x/src/types/PersistOptions.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { PersistOptions as _PersistOptions } from 'zustand/middleware'; - -export type StateStorage = { - getItem: (name: string) => string | null | Promise; - setItem: (name: string, value: string) => void | Promise; -}; -export type StorageValue = { state: S; version: number }; - -type PersistOptionsWithoutName = Omit<_PersistOptions, 'name'>; - -export type PersistOptions = PersistOptionsWithoutName & { - enabled?: boolean; - name?: string; -}; diff --git a/packages/zustand-x/src/types/index.ts b/packages/zustand-x/src/types/index.ts deleted file mode 100644 index 202c65d..0000000 --- a/packages/zustand-x/src/types/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -/** - * @file Automatically generated by barrelsby. - */ - -export * from './CreateStoreOptions'; -export * from './ImmerOptions'; -export * from './PersistOptions'; diff --git a/packages/zustand-x/src/utils/extendActions.ts b/packages/zustand-x/src/utils/extendActions.ts index 32ba40c..972fd7f 100644 --- a/packages/zustand-x/src/utils/extendActions.ts +++ b/packages/zustand-x/src/utils/extendActions.ts @@ -16,14 +16,6 @@ export const extendActions = < TSelectors > => { const actions = builder(api.set, api.get, api); - // Object.keys(actions).forEach((key) => { - // actions[key] = (...args: any[]) => { - // // React batch - // batch(() => { - // actions[key](...args); - // }); - // }; - // }); return { ...(api as any), diff --git a/packages/zustand-x/src/utils/extendSelectors.ts b/packages/zustand-x/src/utils/extendSelectors.ts index 3586a61..1b8d7ff 100644 --- a/packages/zustand-x/src/utils/extendSelectors.ts +++ b/packages/zustand-x/src/utils/extendSelectors.ts @@ -1,56 +1,56 @@ -import { - SelectorBuilder, - State, - StateActions, - StoreApi, - StoreApiGet, - StoreApiUse, - StoreApiUseTracked, -} from '../types'; +import { TSelectorBuilder, TStateApi } from './types.v2'; export const extendSelectors = < - CB extends SelectorBuilder, + Builder extends TSelectorBuilder< + TName, + StateType, + MutatedStateType, + TActions, + TSelectors + >, TName extends string, - T extends State = {}, - TActions = {}, - TSelectors = {}, + StateType, + MutatedStateType, + TActions, + TSelectors, >( - builder: CB, - api: StoreApi & TActions, TSelectors> -): StoreApi< + builder: Builder, + api: TStateApi +): TStateApi< TName, - T, - StateActions & TActions, - TSelectors & ReturnType + StateType, + MutatedStateType, + TActions, + TSelectors & ReturnType > => { const use = { ...api.use, - } as StoreApiUse>; + }; const useTracked = { ...api.useTracked, - } as StoreApiUseTracked>; + }; const get = { ...api.get, - } as StoreApiGet>; + }; Object.keys(builder(api.store.getState(), api.get, api)).forEach((key) => { - // @ts-ignore + //@ts-ignore use[key] = (...args: any[]) => api.useStore((state) => { const selectors = builder(state, api.get, api); const selector = selectors[key]; return selector(...args); }); - // @ts-ignore + //@ts-ignore useTracked[key] = (...args: any[]) => { const trackedState = api.useTrackedStore(); const selectors = builder(trackedState, api.get, api); const selector = selectors[key]; return selector(...args); }; - // @ts-ignore + //@ts-ignore get[key] = (...args: any[]) => { const selectors = builder(api.store.getState(), api.get, api); const selector = selectors[key]; @@ -59,7 +59,7 @@ export const extendSelectors = < }); return { - ...(api as any), + ...api, get, use, useTracked, diff --git a/packages/zustand-x/src/utils/generateStateActions.ts b/packages/zustand-x/src/utils/generateStateActions.ts index 28da8e9..e968bb9 100644 --- a/packages/zustand-x/src/utils/generateStateActions.ts +++ b/packages/zustand-x/src/utils/generateStateActions.ts @@ -1,21 +1,25 @@ -import { ImmerStoreApi, SetRecord, State } from '../types'; +import { TCreatedStoreType, TSetRecord } from './types.v2'; -export const generateStateActions = ( - store: ImmerStoreApi, +export const generateStateActions = ( + store: TCreatedStoreType, storeName: string ) => { - const actions: SetRecord = {} as any; + const actions: TSetRecord = {} as TSetRecord; - Object.keys((store as any).getState()).forEach((key) => { + Object.keys(store.getState() || {}).forEach((key) => { actions[key as keyof T] = (value) => { const prevValue = store.getState()[key as keyof T]; if (prevValue === value) return; const actionKey = key.replace(/^\S/, (s) => s.toUpperCase()); - store.setState((draft) => { - // @ts-ignore - draft[key] = value; - }, `@@${storeName}/set${actionKey}`); + store.setState( + (state) => { + state[key as keyof T] = value; + return state; + }, + undefined, + `@@${storeName}/set${actionKey}` + ); }; }); diff --git a/packages/zustand-x/src/utils/generateStateGetSelectors.ts b/packages/zustand-x/src/utils/generateStateGetSelectors.ts index aa3c2f4..bb7a614 100644 --- a/packages/zustand-x/src/utils/generateStateGetSelectors.ts +++ b/packages/zustand-x/src/utils/generateStateGetSelectors.ts @@ -1,12 +1,9 @@ -import { GetRecord, ImmerStoreApi, State } from '../types'; +import { TGetSelectorRecord, TReadonlyStoreApi } from './types.v2'; -export const generateStateGetSelectors = ( - store: ImmerStoreApi -) => { - const selectors: GetRecord = {} as any; +export const generateStateGetSelectors = (store: TReadonlyStoreApi) => { + const selectors: TGetSelectorRecord = {} as TGetSelectorRecord; - Object.keys((store as any).getState()).forEach((key) => { - // selectors[`get${capitalize(key)}`] = () => store.getState()[key as keyof T]; + Object.keys(store.getState() || {}).forEach((key) => { selectors[key as keyof T] = () => store.getState()[key as keyof T]; }); diff --git a/packages/zustand-x/src/utils/generateStateHookSelectors.ts b/packages/zustand-x/src/utils/generateStateHookSelectors.ts index 582fef6..79aaec8 100644 --- a/packages/zustand-x/src/utils/generateStateHookSelectors.ts +++ b/packages/zustand-x/src/utils/generateStateHookSelectors.ts @@ -1,21 +1,22 @@ import { - EqualityChecker, - GetRecord, - ImmerStoreApi, - State, - UseImmerStore, -} from '../types'; + TCreatedStoreType, + TEqualityChecker, + TGetRecord, + TStoreSelectorType, +} from './types.v2'; -export const generateStateHookSelectors = ( - useStore: UseImmerStore, - store: ImmerStoreApi +export const generateStateHookSelectors = ( + useStore: ( + selector: TStoreSelectorType, + equalityFn?: TEqualityChecker + ) => R, + store: TCreatedStoreType ) => { - const selectors: GetRecord = {} as any; + const selectors: TGetRecord = {} as TGetRecord; - Object.keys((store as any).getState()).forEach((key) => { - // selectors[`use${capitalize(key)}`] = () => - selectors[key as keyof T] = (equalityFn?: EqualityChecker) => { - return useStore((state: T) => state[key as keyof T], equalityFn); + Object.keys(store.getState() || {}).forEach((key) => { + selectors[key as keyof T] = (equalityFn?: TEqualityChecker) => { + return useStore((state) => state[key as keyof T], equalityFn); }; }); diff --git a/packages/zustand-x/src/utils/generateStateTrackedHooksSelectors.ts b/packages/zustand-x/src/utils/generateStateTrackedHooksSelectors.ts index 34d3710..4a1141e 100644 --- a/packages/zustand-x/src/utils/generateStateTrackedHooksSelectors.ts +++ b/packages/zustand-x/src/utils/generateStateTrackedHooksSelectors.ts @@ -1,12 +1,12 @@ -import { GetRecord, ImmerStoreApi, State } from '../types'; +import { TGetSelectorRecord, TReadonlyStoreApi } from './types.v2'; -export const generateStateTrackedHooksSelectors = ( +export const generateStateTrackedHooksSelectors = ( useTrackedStore: () => T, - store: ImmerStoreApi + store: TReadonlyStoreApi ) => { - const selectors: GetRecord = {} as any; + const selectors: TGetSelectorRecord = {} as TGetSelectorRecord; - Object.keys((store as any).getState()).forEach((key) => { + Object.keys(store.getState() || {}).forEach((key) => { selectors[key as keyof T] = () => { return useTrackedStore()[key as keyof T]; }; diff --git a/packages/zustand-x/src/utils/mapValuesKey.ts b/packages/zustand-x/src/utils/mapValuesKey.ts index 7953431..a61fab1 100644 --- a/packages/zustand-x/src/utils/mapValuesKey.ts +++ b/packages/zustand-x/src/utils/mapValuesKey.ts @@ -8,26 +8,3 @@ export const mapValuesKey = < key: VK, obj: R ) => mapValues(obj, (value) => value[key]) as { [K in keyof R]: R[K][VK] }; - -// export const capitalize = (s: string) => s.charAt(0).toUpperCase() + s.slice(1); -// -// type ValueOf = T[keyof T]; -// -// // todo: hard to map values to key -// export const createRootStore = < -// K extends keyof Input, -// Input extends Record -// >( -// stores: Input -// ) => { -// const rootStore = {}; -// -// Object.keys(stores).forEach((key) => { -// const store = stores[key]; -// rootStore[store.name] = store; -// }); -// -// return rootStore as { -// [P in ValueOf<{ [K in keyof Input]: Input[K]['name'] }>]: Input[P]; -// }; -// }; diff --git a/packages/zustand-x/src/utils/pipe.ts b/packages/zustand-x/src/utils/pipe.ts deleted file mode 100644 index a0db1a3..0000000 --- a/packages/zustand-x/src/utils/pipe.ts +++ /dev/null @@ -1,4247 +0,0 @@ -export function pipe(x0: T0): T0; -export function pipe(x0: T0, f1?: (x: T0) => T1): T1; -export function pipe( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2 -): T2; -export function pipe( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3 -): T3; -export function pipe( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4 -): T4; -export function pipe( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5 -): T5; -export function pipe( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6 -): T6; -export function pipe( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7 -): T7; -export function pipe( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8 -): T8; -export function pipe( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9 -): T9; -export function pipe( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10 -): T10; -export function pipe( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11 -): T11; -export function pipe( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12 -): T12; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13 -): T13; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14 -): T14; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15 -): T15; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16 -): T16; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17 -): T17; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18 -): T18; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19 -): T19; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19, - f20?: (x: T19) => T20 -): T20; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19, - f20?: (x: T19) => T20, - f21?: (x: T20) => T21 -): T21; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19, - f20?: (x: T19) => T20, - f21?: (x: T20) => T21, - f22?: (x: T21) => T22 -): T22; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19, - f20?: (x: T19) => T20, - f21?: (x: T20) => T21, - f22?: (x: T21) => T22, - f23?: (x: T22) => T23 -): T23; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19, - f20?: (x: T19) => T20, - f21?: (x: T20) => T21, - f22?: (x: T21) => T22, - f23?: (x: T22) => T23, - f24?: (x: T23) => T24 -): T24; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19, - f20?: (x: T19) => T20, - f21?: (x: T20) => T21, - f22?: (x: T21) => T22, - f23?: (x: T22) => T23, - f24?: (x: T23) => T24, - f25?: (x: T24) => T25 -): T25; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19, - f20?: (x: T19) => T20, - f21?: (x: T20) => T21, - f22?: (x: T21) => T22, - f23?: (x: T22) => T23, - f24?: (x: T23) => T24, - f25?: (x: T24) => T25, - f26?: (x: T25) => T26 -): T26; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19, - f20?: (x: T19) => T20, - f21?: (x: T20) => T21, - f22?: (x: T21) => T22, - f23?: (x: T22) => T23, - f24?: (x: T23) => T24, - f25?: (x: T24) => T25, - f26?: (x: T25) => T26, - f27?: (x: T26) => T27 -): T27; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19, - f20?: (x: T19) => T20, - f21?: (x: T20) => T21, - f22?: (x: T21) => T22, - f23?: (x: T22) => T23, - f24?: (x: T23) => T24, - f25?: (x: T24) => T25, - f26?: (x: T25) => T26, - f27?: (x: T26) => T27, - f28?: (x: T27) => T28 -): T28; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - T29, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19, - f20?: (x: T19) => T20, - f21?: (x: T20) => T21, - f22?: (x: T21) => T22, - f23?: (x: T22) => T23, - f24?: (x: T23) => T24, - f25?: (x: T24) => T25, - f26?: (x: T25) => T26, - f27?: (x: T26) => T27, - f28?: (x: T27) => T28, - f29?: (x: T28) => T29 -): T29; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - T29, - T30, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19, - f20?: (x: T19) => T20, - f21?: (x: T20) => T21, - f22?: (x: T21) => T22, - f23?: (x: T22) => T23, - f24?: (x: T23) => T24, - f25?: (x: T24) => T25, - f26?: (x: T25) => T26, - f27?: (x: T26) => T27, - f28?: (x: T27) => T28, - f29?: (x: T28) => T29, - f30?: (x: T29) => T30 -): T30; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - T29, - T30, - T31, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19, - f20?: (x: T19) => T20, - f21?: (x: T20) => T21, - f22?: (x: T21) => T22, - f23?: (x: T22) => T23, - f24?: (x: T23) => T24, - f25?: (x: T24) => T25, - f26?: (x: T25) => T26, - f27?: (x: T26) => T27, - f28?: (x: T27) => T28, - f29?: (x: T28) => T29, - f30?: (x: T29) => T30, - f31?: (x: T30) => T31 -): T31; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - T29, - T30, - T31, - T32, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19, - f20?: (x: T19) => T20, - f21?: (x: T20) => T21, - f22?: (x: T21) => T22, - f23?: (x: T22) => T23, - f24?: (x: T23) => T24, - f25?: (x: T24) => T25, - f26?: (x: T25) => T26, - f27?: (x: T26) => T27, - f28?: (x: T27) => T28, - f29?: (x: T28) => T29, - f30?: (x: T29) => T30, - f31?: (x: T30) => T31, - f32?: (x: T31) => T32 -): T32; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - T29, - T30, - T31, - T32, - T33, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19, - f20?: (x: T19) => T20, - f21?: (x: T20) => T21, - f22?: (x: T21) => T22, - f23?: (x: T22) => T23, - f24?: (x: T23) => T24, - f25?: (x: T24) => T25, - f26?: (x: T25) => T26, - f27?: (x: T26) => T27, - f28?: (x: T27) => T28, - f29?: (x: T28) => T29, - f30?: (x: T29) => T30, - f31?: (x: T30) => T31, - f32?: (x: T31) => T32, - f33?: (x: T32) => T33 -): T33; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - T29, - T30, - T31, - T32, - T33, - T34, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19, - f20?: (x: T19) => T20, - f21?: (x: T20) => T21, - f22?: (x: T21) => T22, - f23?: (x: T22) => T23, - f24?: (x: T23) => T24, - f25?: (x: T24) => T25, - f26?: (x: T25) => T26, - f27?: (x: T26) => T27, - f28?: (x: T27) => T28, - f29?: (x: T28) => T29, - f30?: (x: T29) => T30, - f31?: (x: T30) => T31, - f32?: (x: T31) => T32, - f33?: (x: T32) => T33, - f34?: (x: T33) => T34 -): T34; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - T29, - T30, - T31, - T32, - T33, - T34, - T35, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19, - f20?: (x: T19) => T20, - f21?: (x: T20) => T21, - f22?: (x: T21) => T22, - f23?: (x: T22) => T23, - f24?: (x: T23) => T24, - f25?: (x: T24) => T25, - f26?: (x: T25) => T26, - f27?: (x: T26) => T27, - f28?: (x: T27) => T28, - f29?: (x: T28) => T29, - f30?: (x: T29) => T30, - f31?: (x: T30) => T31, - f32?: (x: T31) => T32, - f33?: (x: T32) => T33, - f34?: (x: T33) => T34, - f35?: (x: T34) => T35 -): T35; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - T29, - T30, - T31, - T32, - T33, - T34, - T35, - T36, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19, - f20?: (x: T19) => T20, - f21?: (x: T20) => T21, - f22?: (x: T21) => T22, - f23?: (x: T22) => T23, - f24?: (x: T23) => T24, - f25?: (x: T24) => T25, - f26?: (x: T25) => T26, - f27?: (x: T26) => T27, - f28?: (x: T27) => T28, - f29?: (x: T28) => T29, - f30?: (x: T29) => T30, - f31?: (x: T30) => T31, - f32?: (x: T31) => T32, - f33?: (x: T32) => T33, - f34?: (x: T33) => T34, - f35?: (x: T34) => T35, - f36?: (x: T35) => T36 -): T36; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - T29, - T30, - T31, - T32, - T33, - T34, - T35, - T36, - T37, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19, - f20?: (x: T19) => T20, - f21?: (x: T20) => T21, - f22?: (x: T21) => T22, - f23?: (x: T22) => T23, - f24?: (x: T23) => T24, - f25?: (x: T24) => T25, - f26?: (x: T25) => T26, - f27?: (x: T26) => T27, - f28?: (x: T27) => T28, - f29?: (x: T28) => T29, - f30?: (x: T29) => T30, - f31?: (x: T30) => T31, - f32?: (x: T31) => T32, - f33?: (x: T32) => T33, - f34?: (x: T33) => T34, - f35?: (x: T34) => T35, - f36?: (x: T35) => T36, - f37?: (x: T36) => T37 -): T37; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - T29, - T30, - T31, - T32, - T33, - T34, - T35, - T36, - T37, - T38, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19, - f20?: (x: T19) => T20, - f21?: (x: T20) => T21, - f22?: (x: T21) => T22, - f23?: (x: T22) => T23, - f24?: (x: T23) => T24, - f25?: (x: T24) => T25, - f26?: (x: T25) => T26, - f27?: (x: T26) => T27, - f28?: (x: T27) => T28, - f29?: (x: T28) => T29, - f30?: (x: T29) => T30, - f31?: (x: T30) => T31, - f32?: (x: T31) => T32, - f33?: (x: T32) => T33, - f34?: (x: T33) => T34, - f35?: (x: T34) => T35, - f36?: (x: T35) => T36, - f37?: (x: T36) => T37, - f38?: (x: T37) => T38 -): T38; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - T29, - T30, - T31, - T32, - T33, - T34, - T35, - T36, - T37, - T38, - T39, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19, - f20?: (x: T19) => T20, - f21?: (x: T20) => T21, - f22?: (x: T21) => T22, - f23?: (x: T22) => T23, - f24?: (x: T23) => T24, - f25?: (x: T24) => T25, - f26?: (x: T25) => T26, - f27?: (x: T26) => T27, - f28?: (x: T27) => T28, - f29?: (x: T28) => T29, - f30?: (x: T29) => T30, - f31?: (x: T30) => T31, - f32?: (x: T31) => T32, - f33?: (x: T32) => T33, - f34?: (x: T33) => T34, - f35?: (x: T34) => T35, - f36?: (x: T35) => T36, - f37?: (x: T36) => T37, - f38?: (x: T37) => T38, - f39?: (x: T38) => T39 -): T39; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - T29, - T30, - T31, - T32, - T33, - T34, - T35, - T36, - T37, - T38, - T39, - T40, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19, - f20?: (x: T19) => T20, - f21?: (x: T20) => T21, - f22?: (x: T21) => T22, - f23?: (x: T22) => T23, - f24?: (x: T23) => T24, - f25?: (x: T24) => T25, - f26?: (x: T25) => T26, - f27?: (x: T26) => T27, - f28?: (x: T27) => T28, - f29?: (x: T28) => T29, - f30?: (x: T29) => T30, - f31?: (x: T30) => T31, - f32?: (x: T31) => T32, - f33?: (x: T32) => T33, - f34?: (x: T33) => T34, - f35?: (x: T34) => T35, - f36?: (x: T35) => T36, - f37?: (x: T36) => T37, - f38?: (x: T37) => T38, - f39?: (x: T38) => T39, - f40?: (x: T39) => T40 -): T40; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - T29, - T30, - T31, - T32, - T33, - T34, - T35, - T36, - T37, - T38, - T39, - T40, - T41, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19, - f20?: (x: T19) => T20, - f21?: (x: T20) => T21, - f22?: (x: T21) => T22, - f23?: (x: T22) => T23, - f24?: (x: T23) => T24, - f25?: (x: T24) => T25, - f26?: (x: T25) => T26, - f27?: (x: T26) => T27, - f28?: (x: T27) => T28, - f29?: (x: T28) => T29, - f30?: (x: T29) => T30, - f31?: (x: T30) => T31, - f32?: (x: T31) => T32, - f33?: (x: T32) => T33, - f34?: (x: T33) => T34, - f35?: (x: T34) => T35, - f36?: (x: T35) => T36, - f37?: (x: T36) => T37, - f38?: (x: T37) => T38, - f39?: (x: T38) => T39, - f40?: (x: T39) => T40, - f41?: (x: T40) => T41 -): T41; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - T29, - T30, - T31, - T32, - T33, - T34, - T35, - T36, - T37, - T38, - T39, - T40, - T41, - T42, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19, - f20?: (x: T19) => T20, - f21?: (x: T20) => T21, - f22?: (x: T21) => T22, - f23?: (x: T22) => T23, - f24?: (x: T23) => T24, - f25?: (x: T24) => T25, - f26?: (x: T25) => T26, - f27?: (x: T26) => T27, - f28?: (x: T27) => T28, - f29?: (x: T28) => T29, - f30?: (x: T29) => T30, - f31?: (x: T30) => T31, - f32?: (x: T31) => T32, - f33?: (x: T32) => T33, - f34?: (x: T33) => T34, - f35?: (x: T34) => T35, - f36?: (x: T35) => T36, - f37?: (x: T36) => T37, - f38?: (x: T37) => T38, - f39?: (x: T38) => T39, - f40?: (x: T39) => T40, - f41?: (x: T40) => T41, - f42?: (x: T41) => T42 -): T42; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - T29, - T30, - T31, - T32, - T33, - T34, - T35, - T36, - T37, - T38, - T39, - T40, - T41, - T42, - T43, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19, - f20?: (x: T19) => T20, - f21?: (x: T20) => T21, - f22?: (x: T21) => T22, - f23?: (x: T22) => T23, - f24?: (x: T23) => T24, - f25?: (x: T24) => T25, - f26?: (x: T25) => T26, - f27?: (x: T26) => T27, - f28?: (x: T27) => T28, - f29?: (x: T28) => T29, - f30?: (x: T29) => T30, - f31?: (x: T30) => T31, - f32?: (x: T31) => T32, - f33?: (x: T32) => T33, - f34?: (x: T33) => T34, - f35?: (x: T34) => T35, - f36?: (x: T35) => T36, - f37?: (x: T36) => T37, - f38?: (x: T37) => T38, - f39?: (x: T38) => T39, - f40?: (x: T39) => T40, - f41?: (x: T40) => T41, - f42?: (x: T41) => T42, - f43?: (x: T42) => T43 -): T43; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - T29, - T30, - T31, - T32, - T33, - T34, - T35, - T36, - T37, - T38, - T39, - T40, - T41, - T42, - T43, - T44, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19, - f20?: (x: T19) => T20, - f21?: (x: T20) => T21, - f22?: (x: T21) => T22, - f23?: (x: T22) => T23, - f24?: (x: T23) => T24, - f25?: (x: T24) => T25, - f26?: (x: T25) => T26, - f27?: (x: T26) => T27, - f28?: (x: T27) => T28, - f29?: (x: T28) => T29, - f30?: (x: T29) => T30, - f31?: (x: T30) => T31, - f32?: (x: T31) => T32, - f33?: (x: T32) => T33, - f34?: (x: T33) => T34, - f35?: (x: T34) => T35, - f36?: (x: T35) => T36, - f37?: (x: T36) => T37, - f38?: (x: T37) => T38, - f39?: (x: T38) => T39, - f40?: (x: T39) => T40, - f41?: (x: T40) => T41, - f42?: (x: T41) => T42, - f43?: (x: T42) => T43, - f44?: (x: T43) => T44 -): T44; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - T29, - T30, - T31, - T32, - T33, - T34, - T35, - T36, - T37, - T38, - T39, - T40, - T41, - T42, - T43, - T44, - T45, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19, - f20?: (x: T19) => T20, - f21?: (x: T20) => T21, - f22?: (x: T21) => T22, - f23?: (x: T22) => T23, - f24?: (x: T23) => T24, - f25?: (x: T24) => T25, - f26?: (x: T25) => T26, - f27?: (x: T26) => T27, - f28?: (x: T27) => T28, - f29?: (x: T28) => T29, - f30?: (x: T29) => T30, - f31?: (x: T30) => T31, - f32?: (x: T31) => T32, - f33?: (x: T32) => T33, - f34?: (x: T33) => T34, - f35?: (x: T34) => T35, - f36?: (x: T35) => T36, - f37?: (x: T36) => T37, - f38?: (x: T37) => T38, - f39?: (x: T38) => T39, - f40?: (x: T39) => T40, - f41?: (x: T40) => T41, - f42?: (x: T41) => T42, - f43?: (x: T42) => T43, - f44?: (x: T43) => T44, - f45?: (x: T44) => T45 -): T45; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - T29, - T30, - T31, - T32, - T33, - T34, - T35, - T36, - T37, - T38, - T39, - T40, - T41, - T42, - T43, - T44, - T45, - T46, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19, - f20?: (x: T19) => T20, - f21?: (x: T20) => T21, - f22?: (x: T21) => T22, - f23?: (x: T22) => T23, - f24?: (x: T23) => T24, - f25?: (x: T24) => T25, - f26?: (x: T25) => T26, - f27?: (x: T26) => T27, - f28?: (x: T27) => T28, - f29?: (x: T28) => T29, - f30?: (x: T29) => T30, - f31?: (x: T30) => T31, - f32?: (x: T31) => T32, - f33?: (x: T32) => T33, - f34?: (x: T33) => T34, - f35?: (x: T34) => T35, - f36?: (x: T35) => T36, - f37?: (x: T36) => T37, - f38?: (x: T37) => T38, - f39?: (x: T38) => T39, - f40?: (x: T39) => T40, - f41?: (x: T40) => T41, - f42?: (x: T41) => T42, - f43?: (x: T42) => T43, - f44?: (x: T43) => T44, - f45?: (x: T44) => T45, - f46?: (x: T45) => T46 -): T46; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - T29, - T30, - T31, - T32, - T33, - T34, - T35, - T36, - T37, - T38, - T39, - T40, - T41, - T42, - T43, - T44, - T45, - T46, - T47, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19, - f20?: (x: T19) => T20, - f21?: (x: T20) => T21, - f22?: (x: T21) => T22, - f23?: (x: T22) => T23, - f24?: (x: T23) => T24, - f25?: (x: T24) => T25, - f26?: (x: T25) => T26, - f27?: (x: T26) => T27, - f28?: (x: T27) => T28, - f29?: (x: T28) => T29, - f30?: (x: T29) => T30, - f31?: (x: T30) => T31, - f32?: (x: T31) => T32, - f33?: (x: T32) => T33, - f34?: (x: T33) => T34, - f35?: (x: T34) => T35, - f36?: (x: T35) => T36, - f37?: (x: T36) => T37, - f38?: (x: T37) => T38, - f39?: (x: T38) => T39, - f40?: (x: T39) => T40, - f41?: (x: T40) => T41, - f42?: (x: T41) => T42, - f43?: (x: T42) => T43, - f44?: (x: T43) => T44, - f45?: (x: T44) => T45, - f46?: (x: T45) => T46, - f47?: (x: T46) => T47 -): T47; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - T29, - T30, - T31, - T32, - T33, - T34, - T35, - T36, - T37, - T38, - T39, - T40, - T41, - T42, - T43, - T44, - T45, - T46, - T47, - T48, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19, - f20?: (x: T19) => T20, - f21?: (x: T20) => T21, - f22?: (x: T21) => T22, - f23?: (x: T22) => T23, - f24?: (x: T23) => T24, - f25?: (x: T24) => T25, - f26?: (x: T25) => T26, - f27?: (x: T26) => T27, - f28?: (x: T27) => T28, - f29?: (x: T28) => T29, - f30?: (x: T29) => T30, - f31?: (x: T30) => T31, - f32?: (x: T31) => T32, - f33?: (x: T32) => T33, - f34?: (x: T33) => T34, - f35?: (x: T34) => T35, - f36?: (x: T35) => T36, - f37?: (x: T36) => T37, - f38?: (x: T37) => T38, - f39?: (x: T38) => T39, - f40?: (x: T39) => T40, - f41?: (x: T40) => T41, - f42?: (x: T41) => T42, - f43?: (x: T42) => T43, - f44?: (x: T43) => T44, - f45?: (x: T44) => T45, - f46?: (x: T45) => T46, - f47?: (x: T46) => T47, - f48?: (x: T47) => T48 -): T48; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - T29, - T30, - T31, - T32, - T33, - T34, - T35, - T36, - T37, - T38, - T39, - T40, - T41, - T42, - T43, - T44, - T45, - T46, - T47, - T48, - T49, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19, - f20?: (x: T19) => T20, - f21?: (x: T20) => T21, - f22?: (x: T21) => T22, - f23?: (x: T22) => T23, - f24?: (x: T23) => T24, - f25?: (x: T24) => T25, - f26?: (x: T25) => T26, - f27?: (x: T26) => T27, - f28?: (x: T27) => T28, - f29?: (x: T28) => T29, - f30?: (x: T29) => T30, - f31?: (x: T30) => T31, - f32?: (x: T31) => T32, - f33?: (x: T32) => T33, - f34?: (x: T33) => T34, - f35?: (x: T34) => T35, - f36?: (x: T35) => T36, - f37?: (x: T36) => T37, - f38?: (x: T37) => T38, - f39?: (x: T38) => T39, - f40?: (x: T39) => T40, - f41?: (x: T40) => T41, - f42?: (x: T41) => T42, - f43?: (x: T42) => T43, - f44?: (x: T43) => T44, - f45?: (x: T44) => T45, - f46?: (x: T45) => T46, - f47?: (x: T46) => T47, - f48?: (x: T47) => T48, - f49?: (x: T48) => T49 -): T49; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - T29, - T30, - T31, - T32, - T33, - T34, - T35, - T36, - T37, - T38, - T39, - T40, - T41, - T42, - T43, - T44, - T45, - T46, - T47, - T48, - T49, - T50, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19, - f20?: (x: T19) => T20, - f21?: (x: T20) => T21, - f22?: (x: T21) => T22, - f23?: (x: T22) => T23, - f24?: (x: T23) => T24, - f25?: (x: T24) => T25, - f26?: (x: T25) => T26, - f27?: (x: T26) => T27, - f28?: (x: T27) => T28, - f29?: (x: T28) => T29, - f30?: (x: T29) => T30, - f31?: (x: T30) => T31, - f32?: (x: T31) => T32, - f33?: (x: T32) => T33, - f34?: (x: T33) => T34, - f35?: (x: T34) => T35, - f36?: (x: T35) => T36, - f37?: (x: T36) => T37, - f38?: (x: T37) => T38, - f39?: (x: T38) => T39, - f40?: (x: T39) => T40, - f41?: (x: T40) => T41, - f42?: (x: T41) => T42, - f43?: (x: T42) => T43, - f44?: (x: T43) => T44, - f45?: (x: T44) => T45, - f46?: (x: T45) => T46, - f47?: (x: T46) => T47, - f48?: (x: T47) => T48, - f49?: (x: T48) => T49, - f50?: (x: T49) => T50 -): T50; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - T29, - T30, - T31, - T32, - T33, - T34, - T35, - T36, - T37, - T38, - T39, - T40, - T41, - T42, - T43, - T44, - T45, - T46, - T47, - T48, - T49, - T50, - T51, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19, - f20?: (x: T19) => T20, - f21?: (x: T20) => T21, - f22?: (x: T21) => T22, - f23?: (x: T22) => T23, - f24?: (x: T23) => T24, - f25?: (x: T24) => T25, - f26?: (x: T25) => T26, - f27?: (x: T26) => T27, - f28?: (x: T27) => T28, - f29?: (x: T28) => T29, - f30?: (x: T29) => T30, - f31?: (x: T30) => T31, - f32?: (x: T31) => T32, - f33?: (x: T32) => T33, - f34?: (x: T33) => T34, - f35?: (x: T34) => T35, - f36?: (x: T35) => T36, - f37?: (x: T36) => T37, - f38?: (x: T37) => T38, - f39?: (x: T38) => T39, - f40?: (x: T39) => T40, - f41?: (x: T40) => T41, - f42?: (x: T41) => T42, - f43?: (x: T42) => T43, - f44?: (x: T43) => T44, - f45?: (x: T44) => T45, - f46?: (x: T45) => T46, - f47?: (x: T46) => T47, - f48?: (x: T47) => T48, - f49?: (x: T48) => T49, - f50?: (x: T49) => T50, - f51?: (x: T50) => T51 -): T51; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - T29, - T30, - T31, - T32, - T33, - T34, - T35, - T36, - T37, - T38, - T39, - T40, - T41, - T42, - T43, - T44, - T45, - T46, - T47, - T48, - T49, - T50, - T51, - T52, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19, - f20?: (x: T19) => T20, - f21?: (x: T20) => T21, - f22?: (x: T21) => T22, - f23?: (x: T22) => T23, - f24?: (x: T23) => T24, - f25?: (x: T24) => T25, - f26?: (x: T25) => T26, - f27?: (x: T26) => T27, - f28?: (x: T27) => T28, - f29?: (x: T28) => T29, - f30?: (x: T29) => T30, - f31?: (x: T30) => T31, - f32?: (x: T31) => T32, - f33?: (x: T32) => T33, - f34?: (x: T33) => T34, - f35?: (x: T34) => T35, - f36?: (x: T35) => T36, - f37?: (x: T36) => T37, - f38?: (x: T37) => T38, - f39?: (x: T38) => T39, - f40?: (x: T39) => T40, - f41?: (x: T40) => T41, - f42?: (x: T41) => T42, - f43?: (x: T42) => T43, - f44?: (x: T43) => T44, - f45?: (x: T44) => T45, - f46?: (x: T45) => T46, - f47?: (x: T46) => T47, - f48?: (x: T47) => T48, - f49?: (x: T48) => T49, - f50?: (x: T49) => T50, - f51?: (x: T50) => T51, - f52?: (x: T51) => T52 -): T52; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - T29, - T30, - T31, - T32, - T33, - T34, - T35, - T36, - T37, - T38, - T39, - T40, - T41, - T42, - T43, - T44, - T45, - T46, - T47, - T48, - T49, - T50, - T51, - T52, - T53, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19, - f20?: (x: T19) => T20, - f21?: (x: T20) => T21, - f22?: (x: T21) => T22, - f23?: (x: T22) => T23, - f24?: (x: T23) => T24, - f25?: (x: T24) => T25, - f26?: (x: T25) => T26, - f27?: (x: T26) => T27, - f28?: (x: T27) => T28, - f29?: (x: T28) => T29, - f30?: (x: T29) => T30, - f31?: (x: T30) => T31, - f32?: (x: T31) => T32, - f33?: (x: T32) => T33, - f34?: (x: T33) => T34, - f35?: (x: T34) => T35, - f36?: (x: T35) => T36, - f37?: (x: T36) => T37, - f38?: (x: T37) => T38, - f39?: (x: T38) => T39, - f40?: (x: T39) => T40, - f41?: (x: T40) => T41, - f42?: (x: T41) => T42, - f43?: (x: T42) => T43, - f44?: (x: T43) => T44, - f45?: (x: T44) => T45, - f46?: (x: T45) => T46, - f47?: (x: T46) => T47, - f48?: (x: T47) => T48, - f49?: (x: T48) => T49, - f50?: (x: T49) => T50, - f51?: (x: T50) => T51, - f52?: (x: T51) => T52, - f53?: (x: T52) => T53 -): T53; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - T29, - T30, - T31, - T32, - T33, - T34, - T35, - T36, - T37, - T38, - T39, - T40, - T41, - T42, - T43, - T44, - T45, - T46, - T47, - T48, - T49, - T50, - T51, - T52, - T53, - T54, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19, - f20?: (x: T19) => T20, - f21?: (x: T20) => T21, - f22?: (x: T21) => T22, - f23?: (x: T22) => T23, - f24?: (x: T23) => T24, - f25?: (x: T24) => T25, - f26?: (x: T25) => T26, - f27?: (x: T26) => T27, - f28?: (x: T27) => T28, - f29?: (x: T28) => T29, - f30?: (x: T29) => T30, - f31?: (x: T30) => T31, - f32?: (x: T31) => T32, - f33?: (x: T32) => T33, - f34?: (x: T33) => T34, - f35?: (x: T34) => T35, - f36?: (x: T35) => T36, - f37?: (x: T36) => T37, - f38?: (x: T37) => T38, - f39?: (x: T38) => T39, - f40?: (x: T39) => T40, - f41?: (x: T40) => T41, - f42?: (x: T41) => T42, - f43?: (x: T42) => T43, - f44?: (x: T43) => T44, - f45?: (x: T44) => T45, - f46?: (x: T45) => T46, - f47?: (x: T46) => T47, - f48?: (x: T47) => T48, - f49?: (x: T48) => T49, - f50?: (x: T49) => T50, - f51?: (x: T50) => T51, - f52?: (x: T51) => T52, - f53?: (x: T52) => T53, - f54?: (x: T53) => T54 -): T54; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - T29, - T30, - T31, - T32, - T33, - T34, - T35, - T36, - T37, - T38, - T39, - T40, - T41, - T42, - T43, - T44, - T45, - T46, - T47, - T48, - T49, - T50, - T51, - T52, - T53, - T54, - T55, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19, - f20?: (x: T19) => T20, - f21?: (x: T20) => T21, - f22?: (x: T21) => T22, - f23?: (x: T22) => T23, - f24?: (x: T23) => T24, - f25?: (x: T24) => T25, - f26?: (x: T25) => T26, - f27?: (x: T26) => T27, - f28?: (x: T27) => T28, - f29?: (x: T28) => T29, - f30?: (x: T29) => T30, - f31?: (x: T30) => T31, - f32?: (x: T31) => T32, - f33?: (x: T32) => T33, - f34?: (x: T33) => T34, - f35?: (x: T34) => T35, - f36?: (x: T35) => T36, - f37?: (x: T36) => T37, - f38?: (x: T37) => T38, - f39?: (x: T38) => T39, - f40?: (x: T39) => T40, - f41?: (x: T40) => T41, - f42?: (x: T41) => T42, - f43?: (x: T42) => T43, - f44?: (x: T43) => T44, - f45?: (x: T44) => T45, - f46?: (x: T45) => T46, - f47?: (x: T46) => T47, - f48?: (x: T47) => T48, - f49?: (x: T48) => T49, - f50?: (x: T49) => T50, - f51?: (x: T50) => T51, - f52?: (x: T51) => T52, - f53?: (x: T52) => T53, - f54?: (x: T53) => T54, - f55?: (x: T54) => T55 -): T55; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - T29, - T30, - T31, - T32, - T33, - T34, - T35, - T36, - T37, - T38, - T39, - T40, - T41, - T42, - T43, - T44, - T45, - T46, - T47, - T48, - T49, - T50, - T51, - T52, - T53, - T54, - T55, - T56, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19, - f20?: (x: T19) => T20, - f21?: (x: T20) => T21, - f22?: (x: T21) => T22, - f23?: (x: T22) => T23, - f24?: (x: T23) => T24, - f25?: (x: T24) => T25, - f26?: (x: T25) => T26, - f27?: (x: T26) => T27, - f28?: (x: T27) => T28, - f29?: (x: T28) => T29, - f30?: (x: T29) => T30, - f31?: (x: T30) => T31, - f32?: (x: T31) => T32, - f33?: (x: T32) => T33, - f34?: (x: T33) => T34, - f35?: (x: T34) => T35, - f36?: (x: T35) => T36, - f37?: (x: T36) => T37, - f38?: (x: T37) => T38, - f39?: (x: T38) => T39, - f40?: (x: T39) => T40, - f41?: (x: T40) => T41, - f42?: (x: T41) => T42, - f43?: (x: T42) => T43, - f44?: (x: T43) => T44, - f45?: (x: T44) => T45, - f46?: (x: T45) => T46, - f47?: (x: T46) => T47, - f48?: (x: T47) => T48, - f49?: (x: T48) => T49, - f50?: (x: T49) => T50, - f51?: (x: T50) => T51, - f52?: (x: T51) => T52, - f53?: (x: T52) => T53, - f54?: (x: T53) => T54, - f55?: (x: T54) => T55, - f56?: (x: T55) => T56 -): T56; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - T29, - T30, - T31, - T32, - T33, - T34, - T35, - T36, - T37, - T38, - T39, - T40, - T41, - T42, - T43, - T44, - T45, - T46, - T47, - T48, - T49, - T50, - T51, - T52, - T53, - T54, - T55, - T56, - T57, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19, - f20?: (x: T19) => T20, - f21?: (x: T20) => T21, - f22?: (x: T21) => T22, - f23?: (x: T22) => T23, - f24?: (x: T23) => T24, - f25?: (x: T24) => T25, - f26?: (x: T25) => T26, - f27?: (x: T26) => T27, - f28?: (x: T27) => T28, - f29?: (x: T28) => T29, - f30?: (x: T29) => T30, - f31?: (x: T30) => T31, - f32?: (x: T31) => T32, - f33?: (x: T32) => T33, - f34?: (x: T33) => T34, - f35?: (x: T34) => T35, - f36?: (x: T35) => T36, - f37?: (x: T36) => T37, - f38?: (x: T37) => T38, - f39?: (x: T38) => T39, - f40?: (x: T39) => T40, - f41?: (x: T40) => T41, - f42?: (x: T41) => T42, - f43?: (x: T42) => T43, - f44?: (x: T43) => T44, - f45?: (x: T44) => T45, - f46?: (x: T45) => T46, - f47?: (x: T46) => T47, - f48?: (x: T47) => T48, - f49?: (x: T48) => T49, - f50?: (x: T49) => T50, - f51?: (x: T50) => T51, - f52?: (x: T51) => T52, - f53?: (x: T52) => T53, - f54?: (x: T53) => T54, - f55?: (x: T54) => T55, - f56?: (x: T55) => T56, - f57?: (x: T56) => T57 -): T57; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - T29, - T30, - T31, - T32, - T33, - T34, - T35, - T36, - T37, - T38, - T39, - T40, - T41, - T42, - T43, - T44, - T45, - T46, - T47, - T48, - T49, - T50, - T51, - T52, - T53, - T54, - T55, - T56, - T57, - T58, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19, - f20?: (x: T19) => T20, - f21?: (x: T20) => T21, - f22?: (x: T21) => T22, - f23?: (x: T22) => T23, - f24?: (x: T23) => T24, - f25?: (x: T24) => T25, - f26?: (x: T25) => T26, - f27?: (x: T26) => T27, - f28?: (x: T27) => T28, - f29?: (x: T28) => T29, - f30?: (x: T29) => T30, - f31?: (x: T30) => T31, - f32?: (x: T31) => T32, - f33?: (x: T32) => T33, - f34?: (x: T33) => T34, - f35?: (x: T34) => T35, - f36?: (x: T35) => T36, - f37?: (x: T36) => T37, - f38?: (x: T37) => T38, - f39?: (x: T38) => T39, - f40?: (x: T39) => T40, - f41?: (x: T40) => T41, - f42?: (x: T41) => T42, - f43?: (x: T42) => T43, - f44?: (x: T43) => T44, - f45?: (x: T44) => T45, - f46?: (x: T45) => T46, - f47?: (x: T46) => T47, - f48?: (x: T47) => T48, - f49?: (x: T48) => T49, - f50?: (x: T49) => T50, - f51?: (x: T50) => T51, - f52?: (x: T51) => T52, - f53?: (x: T52) => T53, - f54?: (x: T53) => T54, - f55?: (x: T54) => T55, - f56?: (x: T55) => T56, - f57?: (x: T56) => T57, - f58?: (x: T57) => T58 -): T58; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - T29, - T30, - T31, - T32, - T33, - T34, - T35, - T36, - T37, - T38, - T39, - T40, - T41, - T42, - T43, - T44, - T45, - T46, - T47, - T48, - T49, - T50, - T51, - T52, - T53, - T54, - T55, - T56, - T57, - T58, - T59, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19, - f20?: (x: T19) => T20, - f21?: (x: T20) => T21, - f22?: (x: T21) => T22, - f23?: (x: T22) => T23, - f24?: (x: T23) => T24, - f25?: (x: T24) => T25, - f26?: (x: T25) => T26, - f27?: (x: T26) => T27, - f28?: (x: T27) => T28, - f29?: (x: T28) => T29, - f30?: (x: T29) => T30, - f31?: (x: T30) => T31, - f32?: (x: T31) => T32, - f33?: (x: T32) => T33, - f34?: (x: T33) => T34, - f35?: (x: T34) => T35, - f36?: (x: T35) => T36, - f37?: (x: T36) => T37, - f38?: (x: T37) => T38, - f39?: (x: T38) => T39, - f40?: (x: T39) => T40, - f41?: (x: T40) => T41, - f42?: (x: T41) => T42, - f43?: (x: T42) => T43, - f44?: (x: T43) => T44, - f45?: (x: T44) => T45, - f46?: (x: T45) => T46, - f47?: (x: T46) => T47, - f48?: (x: T47) => T48, - f49?: (x: T48) => T49, - f50?: (x: T49) => T50, - f51?: (x: T50) => T51, - f52?: (x: T51) => T52, - f53?: (x: T52) => T53, - f54?: (x: T53) => T54, - f55?: (x: T54) => T55, - f56?: (x: T55) => T56, - f57?: (x: T56) => T57, - f58?: (x: T57) => T58, - f59?: (x: T58) => T59 -): T59; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - T29, - T30, - T31, - T32, - T33, - T34, - T35, - T36, - T37, - T38, - T39, - T40, - T41, - T42, - T43, - T44, - T45, - T46, - T47, - T48, - T49, - T50, - T51, - T52, - T53, - T54, - T55, - T56, - T57, - T58, - T59, - T60, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19, - f20?: (x: T19) => T20, - f21?: (x: T20) => T21, - f22?: (x: T21) => T22, - f23?: (x: T22) => T23, - f24?: (x: T23) => T24, - f25?: (x: T24) => T25, - f26?: (x: T25) => T26, - f27?: (x: T26) => T27, - f28?: (x: T27) => T28, - f29?: (x: T28) => T29, - f30?: (x: T29) => T30, - f31?: (x: T30) => T31, - f32?: (x: T31) => T32, - f33?: (x: T32) => T33, - f34?: (x: T33) => T34, - f35?: (x: T34) => T35, - f36?: (x: T35) => T36, - f37?: (x: T36) => T37, - f38?: (x: T37) => T38, - f39?: (x: T38) => T39, - f40?: (x: T39) => T40, - f41?: (x: T40) => T41, - f42?: (x: T41) => T42, - f43?: (x: T42) => T43, - f44?: (x: T43) => T44, - f45?: (x: T44) => T45, - f46?: (x: T45) => T46, - f47?: (x: T46) => T47, - f48?: (x: T47) => T48, - f49?: (x: T48) => T49, - f50?: (x: T49) => T50, - f51?: (x: T50) => T51, - f52?: (x: T51) => T52, - f53?: (x: T52) => T53, - f54?: (x: T53) => T54, - f55?: (x: T54) => T55, - f56?: (x: T55) => T56, - f57?: (x: T56) => T57, - f58?: (x: T57) => T58, - f59?: (x: T58) => T59, - f60?: (x: T59) => T60 -): T60; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - T29, - T30, - T31, - T32, - T33, - T34, - T35, - T36, - T37, - T38, - T39, - T40, - T41, - T42, - T43, - T44, - T45, - T46, - T47, - T48, - T49, - T50, - T51, - T52, - T53, - T54, - T55, - T56, - T57, - T58, - T59, - T60, - T61, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19, - f20?: (x: T19) => T20, - f21?: (x: T20) => T21, - f22?: (x: T21) => T22, - f23?: (x: T22) => T23, - f24?: (x: T23) => T24, - f25?: (x: T24) => T25, - f26?: (x: T25) => T26, - f27?: (x: T26) => T27, - f28?: (x: T27) => T28, - f29?: (x: T28) => T29, - f30?: (x: T29) => T30, - f31?: (x: T30) => T31, - f32?: (x: T31) => T32, - f33?: (x: T32) => T33, - f34?: (x: T33) => T34, - f35?: (x: T34) => T35, - f36?: (x: T35) => T36, - f37?: (x: T36) => T37, - f38?: (x: T37) => T38, - f39?: (x: T38) => T39, - f40?: (x: T39) => T40, - f41?: (x: T40) => T41, - f42?: (x: T41) => T42, - f43?: (x: T42) => T43, - f44?: (x: T43) => T44, - f45?: (x: T44) => T45, - f46?: (x: T45) => T46, - f47?: (x: T46) => T47, - f48?: (x: T47) => T48, - f49?: (x: T48) => T49, - f50?: (x: T49) => T50, - f51?: (x: T50) => T51, - f52?: (x: T51) => T52, - f53?: (x: T52) => T53, - f54?: (x: T53) => T54, - f55?: (x: T54) => T55, - f56?: (x: T55) => T56, - f57?: (x: T56) => T57, - f58?: (x: T57) => T58, - f59?: (x: T58) => T59, - f60?: (x: T59) => T60, - f61?: (x: T60) => T61 -): T61; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - T29, - T30, - T31, - T32, - T33, - T34, - T35, - T36, - T37, - T38, - T39, - T40, - T41, - T42, - T43, - T44, - T45, - T46, - T47, - T48, - T49, - T50, - T51, - T52, - T53, - T54, - T55, - T56, - T57, - T58, - T59, - T60, - T61, - T62, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19, - f20?: (x: T19) => T20, - f21?: (x: T20) => T21, - f22?: (x: T21) => T22, - f23?: (x: T22) => T23, - f24?: (x: T23) => T24, - f25?: (x: T24) => T25, - f26?: (x: T25) => T26, - f27?: (x: T26) => T27, - f28?: (x: T27) => T28, - f29?: (x: T28) => T29, - f30?: (x: T29) => T30, - f31?: (x: T30) => T31, - f32?: (x: T31) => T32, - f33?: (x: T32) => T33, - f34?: (x: T33) => T34, - f35?: (x: T34) => T35, - f36?: (x: T35) => T36, - f37?: (x: T36) => T37, - f38?: (x: T37) => T38, - f39?: (x: T38) => T39, - f40?: (x: T39) => T40, - f41?: (x: T40) => T41, - f42?: (x: T41) => T42, - f43?: (x: T42) => T43, - f44?: (x: T43) => T44, - f45?: (x: T44) => T45, - f46?: (x: T45) => T46, - f47?: (x: T46) => T47, - f48?: (x: T47) => T48, - f49?: (x: T48) => T49, - f50?: (x: T49) => T50, - f51?: (x: T50) => T51, - f52?: (x: T51) => T52, - f53?: (x: T52) => T53, - f54?: (x: T53) => T54, - f55?: (x: T54) => T55, - f56?: (x: T55) => T56, - f57?: (x: T56) => T57, - f58?: (x: T57) => T58, - f59?: (x: T58) => T59, - f60?: (x: T59) => T60, - f61?: (x: T60) => T61, - f62?: (x: T61) => T62 -): T62; -export function pipe< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - T29, - T30, - T31, - T32, - T33, - T34, - T35, - T36, - T37, - T38, - T39, - T40, - T41, - T42, - T43, - T44, - T45, - T46, - T47, - T48, - T49, - T50, - T51, - T52, - T53, - T54, - T55, - T56, - T57, - T58, - T59, - T60, - T61, - T62, - T63, ->( - x0: T0, - f1?: (x: T0) => T1, - f2?: (x: T1) => T2, - f3?: (x: T2) => T3, - f4?: (x: T3) => T4, - f5?: (x: T4) => T5, - f6?: (x: T5) => T6, - f7?: (x: T6) => T7, - f8?: (x: T7) => T8, - f9?: (x: T8) => T9, - f10?: (x: T9) => T10, - f11?: (x: T10) => T11, - f12?: (x: T11) => T12, - f13?: (x: T12) => T13, - f14?: (x: T13) => T14, - f15?: (x: T14) => T15, - f16?: (x: T15) => T16, - f17?: (x: T16) => T17, - f18?: (x: T17) => T18, - f19?: (x: T18) => T19, - f20?: (x: T19) => T20, - f21?: (x: T20) => T21, - f22?: (x: T21) => T22, - f23?: (x: T22) => T23, - f24?: (x: T23) => T24, - f25?: (x: T24) => T25, - f26?: (x: T25) => T26, - f27?: (x: T26) => T27, - f28?: (x: T27) => T28, - f29?: (x: T28) => T29, - f30?: (x: T29) => T30, - f31?: (x: T30) => T31, - f32?: (x: T31) => T32, - f33?: (x: T32) => T33, - f34?: (x: T33) => T34, - f35?: (x: T34) => T35, - f36?: (x: T35) => T36, - f37?: (x: T36) => T37, - f38?: (x: T37) => T38, - f39?: (x: T38) => T39, - f40?: (x: T39) => T40, - f41?: (x: T40) => T41, - f42?: (x: T41) => T42, - f43?: (x: T42) => T43, - f44?: (x: T43) => T44, - f45?: (x: T44) => T45, - f46?: (x: T45) => T46, - f47?: (x: T46) => T47, - f48?: (x: T47) => T48, - f49?: (x: T48) => T49, - f50?: (x: T49) => T50, - f51?: (x: T50) => T51, - f52?: (x: T51) => T52, - f53?: (x: T52) => T53, - f54?: (x: T53) => T54, - f55?: (x: T54) => T55, - f56?: (x: T55) => T56, - f57?: (x: T56) => T57, - f58?: (x: T57) => T58, - f59?: (x: T58) => T59, - f60?: (x: T59) => T60, - f61?: (x: T60) => T61, - f62?: (x: T61) => T62, - f63?: (x: T62) => T63 -): T63; - -export function pipe(x: any, ...fns: any[]) { - return fns.reduce((y: any, fn) => fn(y), x); -} diff --git a/packages/zustand-x/src/utils/types.v2.ts b/packages/zustand-x/src/utils/types.v2.ts new file mode 100644 index 0000000..346120e --- /dev/null +++ b/packages/zustand-x/src/utils/types.v2.ts @@ -0,0 +1,115 @@ +import { Mutate, StateCreator, StoreApi } from 'zustand'; + +export type TEqualityChecker = ( + state: StateType, + newState: StateType +) => boolean; +export type TGetSelectorRecord = { + [K in keyof O]: () => O[K]; +}; +export type TGetRecord = { + [K in keyof O]: (equalityFn?: TEqualityChecker) => O[K]; +}; +export type TSetRecord = { + [K in keyof O]: (value: O[K]) => void; +}; +export type TStoreSelectorType = ( + state: StateType +) => FilteredStateType; + +export type TEnabledMiddlewares = [ + ['zustand/devtools', never], + ['zustand/persist', MutatedStateType], +]; + +export type TStoreMiddlewareCreatorType< + StateType, + MutatedStateType = StateType, +> = StateCreator]>; +export type TCreatedStoreType = Mutate< + StoreApi, + TEnabledMiddlewares +>; + +export type TReadonlyStoreApi = Pick< + StoreApi, + 'getState' | 'getInitialState' | 'subscribe' +>; + +export type TStateActions = { + state: TCreatedStoreType['setState']; +} & TSetRecord; +export type TStoreGet< + StateType, + TSelectors = {}, +> = TGetSelectorRecord & + TSelectors & { + state: TCreatedStoreType['getState']; + }; +export type TExtractState = S extends { + getState: () => infer StateType; +} + ? StateType + : never; + +export type TStateApi = { + name: TName; + getInitialState: TCreatedStoreType['getInitialState']; + get: TStoreGet; + set: TActions; + store: TCreatedStoreType; + useStore: ( + selector: TStoreSelectorType, + equalityFn?: TEqualityChecker + ) => FilteredStateType; + use: TGetRecord & TSelectors; + useTracked: TGetSelectorRecord & TSelectors; + useTrackedStore: () => StateType; + extendSelectors< + SelectorBuilder extends TSelectorBuilder< + TName, + StateType, + TActions, + TSelectors + >, + >( + builder: SelectorBuilder + ): TStateApi< + TName, + StateType, + TStateActions & TActions, + TSelectors & ReturnType + >; + extendActions< + ActionBuilder extends TActionBuilder< + TName, + StateType, + TStateActions & TActions, + TSelectors + >, + >( + builder: ActionBuilder + ): TStateApi< + TName, + StateType, + TStateActions & TActions & ReturnType, + TSelectors + >; +}; + +export type TSelectorBuilder< + TName, + StateType, + TActions = {}, + TSelectors = {}, +> = ( + state: StateType, + get: TStoreGet & TSelectors, + api: TStateApi +) => any; + +export type TActionBuilder = ( + set: TActions, + get: TStoreGet & TSelectors, + api: TStateApi +) => any; diff --git a/yarn.lock b/yarn.lock index d8a4253..f7ecd07 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9548,7 +9548,7 @@ __metadata: turbowatch: "npm:2.29.4" typedoc: "npm:^0.25.4" typescript: "npm:5.3.3" - zustand: "npm:^4.4.7" + zustand: "npm:5.0.2" languageName: unknown linkType: soft @@ -11134,15 +11134,6 @@ __metadata: languageName: node linkType: hard -"use-sync-external-store@npm:1.2.0": - version: 1.2.0 - resolution: "use-sync-external-store@npm:1.2.0" - peerDependencies: - react: ^16.8.0 || ^17.0.0 || ^18.0.0 - checksum: ac4814e5592524f242921157e791b022efe36e451fe0d4fd4d204322d5433a4fc300d63b0ade5185f8e0735ded044c70bcf6d2352db0f74d097a238cebd2da02 - languageName: node - linkType: hard - "util-deprecate@npm:^1.0.1": version: 1.0.2 resolution: "util-deprecate@npm:1.0.2" @@ -11707,15 +11698,14 @@ __metadata: languageName: unknown linkType: soft -"zustand@npm:^4.4.7": - version: 4.4.7 - resolution: "zustand@npm:4.4.7" - dependencies: - use-sync-external-store: "npm:1.2.0" +"zustand@npm:5.0.2": + version: 5.0.2 + resolution: "zustand@npm:5.0.2" peerDependencies: - "@types/react": ">=16.8" - immer: ">=9.0" - react: ">=16.8" + "@types/react": ">=18.0.0" + immer: ">=9.0.6" + react: ">=18.0.0" + use-sync-external-store: ">=1.2.0" peerDependenciesMeta: "@types/react": optional: true @@ -11723,7 +11713,9 @@ __metadata: optional: true react: optional: true - checksum: de507f09eb79039d74d282df6ffac6c7fb6b840ca3620b0392bcbe3f9049902802db5448b4002e6fcb32f903f7ec1aea14602049eb2a3a8410bfea7186d72fb7 + use-sync-external-store: + optional: true + checksum: d9bb048d8129fd1aaed3fda974991b15a7c9c31ef06f78e9bf5c4b3678f249850764a6dadb8c93127257d07831995cf7a048281658a37c5d1143ad6f397fe37c languageName: node linkType: hard From d860271412d146029fb25924c29a15fc66fab99e Mon Sep 17 00:00:00 2001 From: Arabinda Date: Tue, 24 Dec 2024 20:16:28 +0530 Subject: [PATCH 02/28] fix: rest of the types --- packages/zustand-x/src/createStore.spec.ts | 100 -------- packages/zustand-x/src/createStore.ts | 49 ++-- packages/zustand-x/src/types.ts | 223 ++++++++---------- packages/zustand-x/src/useStore.spec.tsx | 135 ----------- packages/zustand-x/src/utils/extendActions.ts | 27 +-- .../zustand-x/src/utils/extendSelectors.ts | 25 +- .../src/utils/generateStateActions.ts | 2 +- .../src/utils/generateStateGetSelectors.ts | 2 +- .../src/utils/generateStateHookSelectors.ts | 2 +- .../generateStateTrackedHooksSelectors.ts | 2 +- packages/zustand-x/src/utils/storeFactory.ts | 28 --- packages/zustand-x/src/utils/types.v2.ts | 115 --------- 12 files changed, 153 insertions(+), 557 deletions(-) delete mode 100644 packages/zustand-x/src/createStore.spec.ts delete mode 100644 packages/zustand-x/src/useStore.spec.tsx delete mode 100644 packages/zustand-x/src/utils/storeFactory.ts delete mode 100644 packages/zustand-x/src/utils/types.v2.ts diff --git a/packages/zustand-x/src/createStore.spec.ts b/packages/zustand-x/src/createStore.spec.ts deleted file mode 100644 index ee941de..0000000 --- a/packages/zustand-x/src/createStore.spec.ts +++ /dev/null @@ -1,100 +0,0 @@ -import { createStore } from './createStore'; - -describe('zustandX', () => { - describe('when get', () => { - const store = createStore('repo')({ - name: 'zustandX', - stars: 0, - }); - - it('should be', () => { - expect(store.get.name()).toEqual('zustandX'); - }); - }); - - describe('when extending actions', () => { - const store = createStore('repo')({ - name: 'zustandX', - stars: 0, - }) - .extendActions((set, get, api) => ({ - validName: (name: string) => { - set.name(name.trim()); - }, - })) - .extendActions((set, get, api) => ({ - reset: (name: string) => { - set.validName(name); - set.stars(0); - }, - })); - - it('should be', () => { - store.set.reset('test '); - - expect(store.get.state()).toEqual({ - name: 'test', - stars: 0, - }); - }); - }); - - describe('when extending selectors', () => { - const store = createStore('repo')({ - name: 'zustandX ', - stars: 0, - }) - .extendSelectors((set, get, api) => ({ - validName: () => get.name().trim(), - })) - .extendSelectors((set, get, api) => ({ - title: (prefix: string) => - `${prefix + get.validName()} with ${get.stars()} stars`, - })); - - it('should be', () => { - expect(store.get.title('Repository: ')).toBe( - 'Repository: zustandX with 0 stars' - ); - }); - }); - - describe('when set.state', () => { - const store = createStore('repo')({ - name: 'zustandX', - stars: 0, - }); - - it('should be', () => { - store.set.state((draft) => { - draft.name = 'test'; - draft.stars = 1; - }); - - expect(store.get.state()).toEqual({ - name: 'test', - stars: 1, - }); - }); - - describe('deletes a property', () => { - it('should delete that property', () => { - const repoStore = createStore('repo')<{ - name?: string; - stars: number; - }>({ - name: 'zustandX', - stars: 0, - }); - - repoStore.set.state((draft) => { - delete draft.name; - }); - - expect(repoStore.get.state()).toEqual({ - stars: 0, - }); - }); - }); - }); -}); diff --git a/packages/zustand-x/src/createStore.ts b/packages/zustand-x/src/createStore.ts index cdd7982..17c6085 100644 --- a/packages/zustand-x/src/createStore.ts +++ b/packages/zustand-x/src/createStore.ts @@ -8,18 +8,19 @@ import { } from 'zustand/middleware'; import { useStoreWithEqualityFn } from 'zustand/traditional'; -import { extendSelectors } from './utils'; -import { generateStateActions } from './utils/generateStateActions'; -import { generateStateGetSelectors } from './utils/generateStateGetSelectors'; -import { generateStateHookSelectors } from './utils/generateStateHookSelectors'; -import { generateStateTrackedHooksSelectors } from './utils/generateStateTrackedHooksSelectors'; import { + TActionBuilder, TEqualityChecker, - TStateActions, + TSelectorBuilder, TStateApi, TStoreMiddlewareCreatorType, TStoreSelectorType, -} from './utils/types.v2'; +} from './types'; +import { extendActions, extendSelectors } from './utils'; +import { generateStateActions } from './utils/generateStateActions'; +import { generateStateGetSelectors } from './utils/generateStateGetSelectors'; +import { generateStateHookSelectors } from './utils/generateStateHookSelectors'; +import { generateStateTrackedHooksSelectors } from './utils/generateStateTrackedHooksSelectors'; import type { StateCreator, StoreMutatorIdentifier } from 'zustand'; @@ -86,7 +87,7 @@ export const createStore = store ); - const apiInternal: TStateApi> = { + const apiInternal: TStateApi = { getInitialState: store.getInitialState, get: { state: store.getState, @@ -106,20 +107,30 @@ export const createStore = extendActions: () => apiInternal as any, }; - const storeFactory = ( - api: TStateApi> - ) => { - return { - ...api, - extendSelectors: (builder) => - storeFactory(extendSelectors(builder, api)), - } as TStateApi>; - }; + return storeFactory(apiInternal) as TStateApi; + }; - return storeFactory(apiInternal); +const storeFactory = (api: TStateApi) => { + return { + ...api, + extendSelectors: (builder: TSelectorBuilder) => + storeFactory(extendSelectors(builder, api)), + extendActions: (builder: TActionBuilder) => + storeFactory(extendActions(builder, api)), }; +}; -// const a = createStore("a")(()=>({vv:""})) +// const test = createStore('hello')(() => ({ hey: 'aa' })) +// .extendSelectors(() => { +// return { +// selector: 'asas', +// }; +// }) +// .extendActions(() => { +// return { +// action: 'as', +// }; +// }); // Alias {@link createStore} export const createZustandStore = createStore; diff --git a/packages/zustand-x/src/types.ts b/packages/zustand-x/src/types.ts index a5d505e..2d68c58 100644 --- a/packages/zustand-x/src/types.ts +++ b/packages/zustand-x/src/types.ts @@ -1,137 +1,118 @@ -import { Draft } from 'immer'; -import { StoreApi as RawStoreApi, UseBoundStore } from 'zustand'; -import { NamedSet } from 'zustand/middleware'; -import { GetState, StateSelector } from 'zustand/vanilla'; - -export type StoreApiGet< - T extends State = {}, - TSelectors = {}, -> = StateGetters & TSelectors; -export type StoreApiUse = GetRecord & - TSelectors; -export type StoreApiUseTracked< - T extends State = {}, +import { Mutate, StateCreator, StoreApi } from 'zustand'; + +export type TEqualityChecker = ( + state: StateType, + newState: StateType +) => boolean; +export type TGetSelectorRecord = { + [K in keyof O]: () => O[K]; +}; +export type TGetRecord = { + [K in keyof O]: (equalityFn?: TEqualityChecker) => O[K]; +}; +export type TSetRecord = { + [K in keyof O]: (value: O[K]) => void; +}; +export type TStoreSelectorType = ( + state: StateType +) => FilteredStateType; + +export type TEnabledMiddlewares = [ + ['zustand/devtools', never], + ['zustand/persist', MutatedStateType], +]; + +export type TStoreMiddlewareCreatorType< + StateType, + MutatedStateType = StateType, +> = StateCreator]>; +export type TCreatedStoreType = Mutate< + StoreApi, + TEnabledMiddlewares +>; + +export type TReadonlyStoreApi = Pick< + StoreApi, + 'getState' | 'getInitialState' | 'subscribe' +>; + +export type TStoreApiSet = TSetRecord & + TActions & { + state: TCreatedStoreType['setState']; + }; + +export type TStoreApiGet< + StateType, TSelectors = {}, -> = GetRecord & TSelectors; -export type StoreApiSet = TActions; +> = TGetSelectorRecord & + TSelectors & { + state: TCreatedStoreType['getState']; + }; -export type StoreApi< - TName extends string, - T extends State = {}, - TActions = {}, - TSelectors = {}, -> = { - get: StoreApiGet; - name: TName; - set: StoreApiSet; - store: ImmerStoreApi; - use: StoreApiUse; - useTracked: StoreApiUseTracked; - useStore: UseImmerStore; - useTrackedStore: () => T; +export type TExtractState = S extends { + getState: () => infer StateType; +} + ? StateType + : never; - extendSelectors>( - builder: SB - ): StoreApi< +export type TStateApi = { + name: TName; + getInitialState: TCreatedStoreType['getInitialState']; + get: TStoreApiGet; + set: TStoreApiSet; + store: TCreatedStoreType; + useStore: ( + selector: TStoreSelectorType, + equalityFn?: TEqualityChecker + ) => FilteredStateType; + use: TGetRecord & TSelectors; + useTracked: TGetSelectorRecord & TSelectors; + useTrackedStore: () => StateType; + extendSelectors< + SelectorBuilder extends TSelectorBuilder< + TName, + StateType, + TActions, + TSelectors + >, + >( + builder: SelectorBuilder + ): TStateApi< TName, - T, - StateActions & TActions, - TSelectors & ReturnType + StateType, + TStoreApiSet, + TSelectors & ReturnType >; - extendActions< - AB extends ActionBuilder & TActions, TSelectors>, + ActionBuilder extends TActionBuilder< + TName, + StateType, + TActions, + TSelectors + >, >( - builder: AB - ): StoreApi< + builder: ActionBuilder + ): TStateApi< TName, - T, - StateActions & TActions & ReturnType, - TSelectors + StateType, + TActions & ReturnType, + TStoreApiGet >; - - // extendActionsMerge & TActions>>( - // builder: AB - // ): StoreApi< - // TName, - // T, - // StateActions & TActions & ReturnType, - // TSelectors - // >; -}; - -export type State = unknown; -export type EqualityChecker = (state: T, newState: T) => boolean; - -export type MergeState = ( - state: Partial, - actionName?: string -) => void; - -export type StateActions = SetRecord & { - state: SetImmerState; - mergeState: MergeState; -}; -export type StateGetters = GetRecord & { - state: GetState; }; -export type SelectorRecord = Record any>; - -export type SelectorBuilder< - TName extends string, - T extends State, - TActions = {}, - TSelectors = {}, -> = ( - state: T, - get: StoreApiGet, - api: StoreApi -) => Record any>; - -export type ActionBuilder< - TName extends string, - T extends State, +export type TSelectorBuilder< + TName, + StateType, TActions = {}, TSelectors = {}, > = ( - set: StoreApiSet, - get: StoreApiGet, - api: StoreApi + state: StateType, + get: TStoreApiGet, + api: TStateApi ) => any; -export type SetImmerState = ( - fn: (draft: Draft) => void, - actionName?: string -) => void; - -export type StateCreatorWithDevtools< - T extends State, - CustomSetState = NamedSet, - CustomGetState = GetState, - CustomStoreApi extends RawStoreApi = RawStoreApi, -> = (set: CustomSetState, get: CustomGetState, api: CustomStoreApi) => T; - -export interface ImmerStoreApi - extends Omit, 'setState'> { - setState: SetImmerState; -} - -export interface UseImmerStore - extends Omit>, 'setState'> { - (): T; - - (selector: StateSelector, equalityFn?: EqualityChecker): U; - - setState: SetImmerState; -} - -// export type UseRecord = { -// [K in keyof O as `use${Capitalize}`]: () => O[K]; -// }; -// export type GetRecord = { -// [K in keyof O as `get${Capitalize}`]: () => O[K]; -// }; -// export type SetRecord = { -// [K in keyof O as `set${Capitalize}`]: (value: O[K]) => void; -// }; +export type TActionBuilder = ( + set: TStoreApiSet, + get: TStoreApiGet, + api: TStateApi +) => any; diff --git a/packages/zustand-x/src/useStore.spec.tsx b/packages/zustand-x/src/useStore.spec.tsx deleted file mode 100644 index 63d292a..0000000 --- a/packages/zustand-x/src/useStore.spec.tsx +++ /dev/null @@ -1,135 +0,0 @@ -import '@testing-library/jest-dom'; - -import React from 'react'; -import { act, render, renderHook } from '@testing-library/react'; - -import { createZustandStore } from './createStore'; - -describe('createAtomStore', () => { - describe('single provider', () => { - type MyTestStoreValue = { - name: string; - age: number; - }; - - const INITIAL_NAME = 'John'; - const INITIAL_AGE = 42; - - const initialTestStoreValue: MyTestStoreValue = { - name: INITIAL_NAME, - age: INITIAL_AGE, - }; - - const store = createZustandStore('myTestStore')(initialTestStoreValue); - const useSelectors = () => store.use; - const actions = store.set; - const selectors = store.get; - - const ReadOnlyConsumer = () => { - const name = useSelectors().name(); - const age = useSelectors().age(); - - return ( -
- {name} - {age} -
- ); - }; - - const WriteOnlyConsumer = () => { - return ( - - ); - }; - - beforeEach(() => { - renderHook(() => actions.name(INITIAL_NAME)); - renderHook(() => actions.age(INITIAL_AGE)); - }); - - it('read only', () => { - const { getByText } = render(); - - expect(getByText(INITIAL_NAME)).toBeInTheDocument(); - expect(getByText(INITIAL_AGE)).toBeInTheDocument(); - }); - - it('actions', () => { - const { getByText } = render( - <> - - - - ); - expect(getByText(INITIAL_NAME)).toBeInTheDocument(); - expect(getByText(INITIAL_AGE)).toBeInTheDocument(); - - act(() => getByText('consumerSetAge').click()); - - expect(getByText(INITIAL_NAME)).toBeInTheDocument(); - expect(getByText(INITIAL_AGE + 1)).toBeInTheDocument(); - expect(store.store.getState().age).toBe(INITIAL_AGE + 1); - }); - }); - - describe('multiple unrelated stores', () => { - type MyFirstTestStoreValue = { name: string }; - type MySecondTestStoreValue = { age: number }; - - const initialFirstTestStoreValue: MyFirstTestStoreValue = { - name: 'My name', - }; - - const initialSecondTestStoreValue: MySecondTestStoreValue = { - age: 72, - }; - - const myFirstTestStoreStore = createZustandStore('myFirstTestStore')( - initialFirstTestStoreValue - ); - const mySecondTestStoreStore = createZustandStore('mySecondTestStore')( - initialSecondTestStoreValue - ); - - const FirstReadOnlyConsumer = () => { - const name = myFirstTestStoreStore.use.name(); - - return ( -
- {name} -
- ); - }; - - const SecondReadOnlyConsumer = () => { - const age = mySecondTestStoreStore.use.age(); - - return ( -
- {age} -
- ); - }; - - it('returns the value for the correct store', () => { - const { getByText } = render( - <> - - - - ); - - expect(getByText('My name')).toBeInTheDocument(); - expect(getByText(72)).toBeInTheDocument(); - }); - }); -}); diff --git a/packages/zustand-x/src/utils/extendActions.ts b/packages/zustand-x/src/utils/extendActions.ts index 972fd7f..4b06037 100644 --- a/packages/zustand-x/src/utils/extendActions.ts +++ b/packages/zustand-x/src/utils/extendActions.ts @@ -1,27 +1,22 @@ -import { ActionBuilder, State, StateActions, StoreApi } from '../types'; +import { TActionBuilder, TStateApi } from '../types'; export const extendActions = < - AB extends ActionBuilder & TActions, TSelectors>, - TName extends string, - T extends State = {}, - TActions = {}, - TSelectors = {}, ->( - builder: AB, - api: StoreApi & TActions, TSelectors> -): StoreApi< TName, - T, - StateActions & TActions & ReturnType, - TSelectors -> => { + StateType, + TActions, + TSelectors, + Builder extends TActionBuilder, +>( + builder: Builder, + api: TStateApi +) => { const actions = builder(api.set, api.get, api); return { - ...(api as any), + ...api, set: { ...api.set, ...actions, }, - }; + } as TStateApi, TSelectors>; }; diff --git a/packages/zustand-x/src/utils/extendSelectors.ts b/packages/zustand-x/src/utils/extendSelectors.ts index 1b8d7ff..5c16313 100644 --- a/packages/zustand-x/src/utils/extendSelectors.ts +++ b/packages/zustand-x/src/utils/extendSelectors.ts @@ -1,28 +1,15 @@ -import { TSelectorBuilder, TStateApi } from './types.v2'; +import { TSelectorBuilder, TStateApi } from '../types'; export const extendSelectors = < - Builder extends TSelectorBuilder< - TName, - StateType, - MutatedStateType, - TActions, - TSelectors - >, - TName extends string, + TName, StateType, - MutatedStateType, TActions, TSelectors, + Builder extends TSelectorBuilder, >( builder: Builder, - api: TStateApi -): TStateApi< - TName, - StateType, - MutatedStateType, - TActions, - TSelectors & ReturnType -> => { + api: TStateApi +) => { const use = { ...api.use, }; @@ -63,5 +50,5 @@ export const extendSelectors = < get, use, useTracked, - }; + } as TStateApi>; }; diff --git a/packages/zustand-x/src/utils/generateStateActions.ts b/packages/zustand-x/src/utils/generateStateActions.ts index e968bb9..b727196 100644 --- a/packages/zustand-x/src/utils/generateStateActions.ts +++ b/packages/zustand-x/src/utils/generateStateActions.ts @@ -1,4 +1,4 @@ -import { TCreatedStoreType, TSetRecord } from './types.v2'; +import { TCreatedStoreType, TSetRecord } from '../types'; export const generateStateActions = ( store: TCreatedStoreType, diff --git a/packages/zustand-x/src/utils/generateStateGetSelectors.ts b/packages/zustand-x/src/utils/generateStateGetSelectors.ts index bb7a614..f79e420 100644 --- a/packages/zustand-x/src/utils/generateStateGetSelectors.ts +++ b/packages/zustand-x/src/utils/generateStateGetSelectors.ts @@ -1,4 +1,4 @@ -import { TGetSelectorRecord, TReadonlyStoreApi } from './types.v2'; +import { TGetSelectorRecord, TReadonlyStoreApi } from '../types'; export const generateStateGetSelectors = (store: TReadonlyStoreApi) => { const selectors: TGetSelectorRecord = {} as TGetSelectorRecord; diff --git a/packages/zustand-x/src/utils/generateStateHookSelectors.ts b/packages/zustand-x/src/utils/generateStateHookSelectors.ts index 79aaec8..0986816 100644 --- a/packages/zustand-x/src/utils/generateStateHookSelectors.ts +++ b/packages/zustand-x/src/utils/generateStateHookSelectors.ts @@ -3,7 +3,7 @@ import { TEqualityChecker, TGetRecord, TStoreSelectorType, -} from './types.v2'; +} from '../types'; export const generateStateHookSelectors = ( useStore: ( diff --git a/packages/zustand-x/src/utils/generateStateTrackedHooksSelectors.ts b/packages/zustand-x/src/utils/generateStateTrackedHooksSelectors.ts index 4a1141e..0adbf9b 100644 --- a/packages/zustand-x/src/utils/generateStateTrackedHooksSelectors.ts +++ b/packages/zustand-x/src/utils/generateStateTrackedHooksSelectors.ts @@ -1,4 +1,4 @@ -import { TGetSelectorRecord, TReadonlyStoreApi } from './types.v2'; +import { TGetSelectorRecord, TReadonlyStoreApi } from '../types'; export const generateStateTrackedHooksSelectors = ( useTrackedStore: () => T, diff --git a/packages/zustand-x/src/utils/storeFactory.ts b/packages/zustand-x/src/utils/storeFactory.ts deleted file mode 100644 index abdf748..0000000 --- a/packages/zustand-x/src/utils/storeFactory.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { - ActionBuilder, - SelectorBuilder, - State, - StateActions, - StoreApi, -} from '../types'; -import { extendActions } from './extendActions'; -import { extendSelectors } from './extendSelectors'; - -export const storeFactory = < - TName extends string, - T extends State, - TActions = {}, - TSelectors = {}, ->( - api: StoreApi & TActions, TSelectors> -) => { - return { - ...api, - extendSelectors: ( - builder: SelectorBuilder - ) => storeFactory(extendSelectors(builder, api)), - extendActions: ( - builder: ActionBuilder & TActions, TSelectors> - ) => storeFactory(extendActions(builder, api)), - }; -}; diff --git a/packages/zustand-x/src/utils/types.v2.ts b/packages/zustand-x/src/utils/types.v2.ts deleted file mode 100644 index 346120e..0000000 --- a/packages/zustand-x/src/utils/types.v2.ts +++ /dev/null @@ -1,115 +0,0 @@ -import { Mutate, StateCreator, StoreApi } from 'zustand'; - -export type TEqualityChecker = ( - state: StateType, - newState: StateType -) => boolean; -export type TGetSelectorRecord = { - [K in keyof O]: () => O[K]; -}; -export type TGetRecord = { - [K in keyof O]: (equalityFn?: TEqualityChecker) => O[K]; -}; -export type TSetRecord = { - [K in keyof O]: (value: O[K]) => void; -}; -export type TStoreSelectorType = ( - state: StateType -) => FilteredStateType; - -export type TEnabledMiddlewares = [ - ['zustand/devtools', never], - ['zustand/persist', MutatedStateType], -]; - -export type TStoreMiddlewareCreatorType< - StateType, - MutatedStateType = StateType, -> = StateCreator]>; -export type TCreatedStoreType = Mutate< - StoreApi, - TEnabledMiddlewares ->; - -export type TReadonlyStoreApi = Pick< - StoreApi, - 'getState' | 'getInitialState' | 'subscribe' ->; - -export type TStateActions = { - state: TCreatedStoreType['setState']; -} & TSetRecord; -export type TStoreGet< - StateType, - TSelectors = {}, -> = TGetSelectorRecord & - TSelectors & { - state: TCreatedStoreType['getState']; - }; -export type TExtractState = S extends { - getState: () => infer StateType; -} - ? StateType - : never; - -export type TStateApi = { - name: TName; - getInitialState: TCreatedStoreType['getInitialState']; - get: TStoreGet; - set: TActions; - store: TCreatedStoreType; - useStore: ( - selector: TStoreSelectorType, - equalityFn?: TEqualityChecker - ) => FilteredStateType; - use: TGetRecord & TSelectors; - useTracked: TGetSelectorRecord & TSelectors; - useTrackedStore: () => StateType; - extendSelectors< - SelectorBuilder extends TSelectorBuilder< - TName, - StateType, - TActions, - TSelectors - >, - >( - builder: SelectorBuilder - ): TStateApi< - TName, - StateType, - TStateActions & TActions, - TSelectors & ReturnType - >; - extendActions< - ActionBuilder extends TActionBuilder< - TName, - StateType, - TStateActions & TActions, - TSelectors - >, - >( - builder: ActionBuilder - ): TStateApi< - TName, - StateType, - TStateActions & TActions & ReturnType, - TSelectors - >; -}; - -export type TSelectorBuilder< - TName, - StateType, - TActions = {}, - TSelectors = {}, -> = ( - state: StateType, - get: TStoreGet & TSelectors, - api: TStateApi -) => any; - -export type TActionBuilder = ( - set: TActions, - get: TStoreGet & TSelectors, - api: TStateApi -) => any; From 9c048296e60323b60172dee5f89cbcbc556ce12c Mon Sep 17 00:00:00 2001 From: Arabinda Date: Thu, 26 Dec 2024 12:00:56 +0530 Subject: [PATCH 03/28] fix: build error --- package.json | 1 - packages/zustand-x/src/index.ts | 2 -- packages/zustand-x/src/utils/index.ts | 2 -- 3 files changed, 5 deletions(-) diff --git a/package.json b/package.json index abfa03c..1f321a4 100644 --- a/package.json +++ b/package.json @@ -94,7 +94,6 @@ "prettier": "^3.1.0", "react": "^18.2.0", "react-dom": "^18.2.0", - "react-is": "18.2.0", "react-test-renderer": "18.2.0", "rimraf": "^5.0.5", "ts-jest": "^29.1.1", diff --git a/packages/zustand-x/src/index.ts b/packages/zustand-x/src/index.ts index e484c0a..8b881b5 100644 --- a/packages/zustand-x/src/index.ts +++ b/packages/zustand-x/src/index.ts @@ -4,6 +4,4 @@ export * from './createStore'; export * from './types'; -export * from './middlewares/index'; -export * from './types/index'; export * from './utils/index'; diff --git a/packages/zustand-x/src/utils/index.ts b/packages/zustand-x/src/utils/index.ts index 0b50434..ee9c769 100644 --- a/packages/zustand-x/src/utils/index.ts +++ b/packages/zustand-x/src/utils/index.ts @@ -9,5 +9,3 @@ export * from './generateStateGetSelectors'; export * from './generateStateHookSelectors'; export * from './generateStateTrackedHooksSelectors'; export * from './mapValuesKey'; -export * from './pipe'; -export * from './storeFactory'; From f496fbc4c972e36f9801ec2c14fccbd43e82f41e Mon Sep 17 00:00:00 2001 From: Arabinda Date: Thu, 26 Dec 2024 13:05:25 +0530 Subject: [PATCH 04/28] dynamic Mutator types --- packages/zustand-x/src/createStore.ts | 28 +++-- packages/zustand-x/src/index.ts | 2 +- packages/zustand-x/src/types.ts | 118 ------------------ packages/zustand-x/src/types/index.ts | 2 + packages/zustand-x/src/types/store.ts | 107 ++++++++++++++++ packages/zustand-x/src/types/utils.ts | 40 ++++++ .../src/utils/generateStateActions.ts | 19 +-- .../src/utils/generateStateGetSelectors.ts | 12 +- .../src/utils/generateStateHookSelectors.ts | 22 ++-- .../generateStateTrackedHooksSelectors.ts | 15 +-- 10 files changed, 213 insertions(+), 152 deletions(-) delete mode 100644 packages/zustand-x/src/types.ts create mode 100644 packages/zustand-x/src/types/index.ts create mode 100644 packages/zustand-x/src/types/store.ts create mode 100644 packages/zustand-x/src/types/utils.ts diff --git a/packages/zustand-x/src/createStore.ts b/packages/zustand-x/src/createStore.ts index 17c6085..786c596 100644 --- a/packages/zustand-x/src/createStore.ts +++ b/packages/zustand-x/src/createStore.ts @@ -13,7 +13,7 @@ import { TEqualityChecker, TSelectorBuilder, TStateApi, - TStoreMiddlewareCreatorType, + TStoreMiddlewareStateCreatorType, TStoreSelectorType, } from './types'; import { extendActions, extendSelectors } from './utils'; @@ -24,14 +24,18 @@ import { generateStateTrackedHooksSelectors } from './utils/generateStateTracked import type { StateCreator, StoreMutatorIdentifier } from 'zustand'; -type TCreateStoreOptions = { - persist?: Partial> & { +type TCreateStoreOptions = { + persist?: Partial> & { enabled?: boolean; }; devtools?: Partial & { enabled?: boolean; }; }; +type TStoreMiddlewares = [ + ['zustand/devtools', never], + ['zustand/persist', StateType], +]; export const createStore = (name: TName) => < @@ -62,11 +66,11 @@ export const createStore = }) ); } - + type Mutators = [...TStoreMiddlewares, ...Mcs]; const stateMutators = middlewares.reduce( (y: any, fn) => fn(y), createState - ) as TStoreMiddlewareCreatorType; + ) as TStoreMiddlewareStateCreatorType; const store = createStoreZustand(stateMutators); @@ -87,7 +91,7 @@ export const createStore = store ); - const apiInternal: TStateApi = { + const apiInternal: TStateApi = { getInitialState: store.getInitialState, get: { state: store.getState, @@ -107,10 +111,16 @@ export const createStore = extendActions: () => apiInternal as any, }; - return storeFactory(apiInternal) as TStateApi; + return storeFactory(apiInternal) as TStateApi; }; -const storeFactory = (api: TStateApi) => { +const storeFactory = < + TName, + StateType, + Mutators extends [StoreMutatorIdentifier, unknown][] = [], +>( + api: TStateApi +) => { return { ...api, extendSelectors: (builder: TSelectorBuilder) => @@ -132,5 +142,7 @@ const storeFactory = (api: TStateApi) => { // }; // }); +// test.set.action === "" + // Alias {@link createStore} export const createZustandStore = createStore; diff --git a/packages/zustand-x/src/index.ts b/packages/zustand-x/src/index.ts index 8b881b5..9dcdabc 100644 --- a/packages/zustand-x/src/index.ts +++ b/packages/zustand-x/src/index.ts @@ -3,5 +3,5 @@ */ export * from './createStore'; -export * from './types'; +export * from './types/store'; export * from './utils/index'; diff --git a/packages/zustand-x/src/types.ts b/packages/zustand-x/src/types.ts deleted file mode 100644 index 2d68c58..0000000 --- a/packages/zustand-x/src/types.ts +++ /dev/null @@ -1,118 +0,0 @@ -import { Mutate, StateCreator, StoreApi } from 'zustand'; - -export type TEqualityChecker = ( - state: StateType, - newState: StateType -) => boolean; -export type TGetSelectorRecord = { - [K in keyof O]: () => O[K]; -}; -export type TGetRecord = { - [K in keyof O]: (equalityFn?: TEqualityChecker) => O[K]; -}; -export type TSetRecord = { - [K in keyof O]: (value: O[K]) => void; -}; -export type TStoreSelectorType = ( - state: StateType -) => FilteredStateType; - -export type TEnabledMiddlewares = [ - ['zustand/devtools', never], - ['zustand/persist', MutatedStateType], -]; - -export type TStoreMiddlewareCreatorType< - StateType, - MutatedStateType = StateType, -> = StateCreator]>; -export type TCreatedStoreType = Mutate< - StoreApi, - TEnabledMiddlewares ->; - -export type TReadonlyStoreApi = Pick< - StoreApi, - 'getState' | 'getInitialState' | 'subscribe' ->; - -export type TStoreApiSet = TSetRecord & - TActions & { - state: TCreatedStoreType['setState']; - }; - -export type TStoreApiGet< - StateType, - TSelectors = {}, -> = TGetSelectorRecord & - TSelectors & { - state: TCreatedStoreType['getState']; - }; - -export type TExtractState = S extends { - getState: () => infer StateType; -} - ? StateType - : never; - -export type TStateApi = { - name: TName; - getInitialState: TCreatedStoreType['getInitialState']; - get: TStoreApiGet; - set: TStoreApiSet; - store: TCreatedStoreType; - useStore: ( - selector: TStoreSelectorType, - equalityFn?: TEqualityChecker - ) => FilteredStateType; - use: TGetRecord & TSelectors; - useTracked: TGetSelectorRecord & TSelectors; - useTrackedStore: () => StateType; - extendSelectors< - SelectorBuilder extends TSelectorBuilder< - TName, - StateType, - TActions, - TSelectors - >, - >( - builder: SelectorBuilder - ): TStateApi< - TName, - StateType, - TStoreApiSet, - TSelectors & ReturnType - >; - extendActions< - ActionBuilder extends TActionBuilder< - TName, - StateType, - TActions, - TSelectors - >, - >( - builder: ActionBuilder - ): TStateApi< - TName, - StateType, - TActions & ReturnType, - TStoreApiGet - >; -}; - -export type TSelectorBuilder< - TName, - StateType, - TActions = {}, - TSelectors = {}, -> = ( - state: StateType, - get: TStoreApiGet, - api: TStateApi -) => any; - -export type TActionBuilder = ( - set: TStoreApiSet, - get: TStoreApiGet, - api: TStateApi -) => any; diff --git a/packages/zustand-x/src/types/index.ts b/packages/zustand-x/src/types/index.ts new file mode 100644 index 0000000..aa37d8c --- /dev/null +++ b/packages/zustand-x/src/types/index.ts @@ -0,0 +1,2 @@ +export * from './store'; +export * from './utils'; diff --git a/packages/zustand-x/src/types/store.ts b/packages/zustand-x/src/types/store.ts new file mode 100644 index 0000000..7506264 --- /dev/null +++ b/packages/zustand-x/src/types/store.ts @@ -0,0 +1,107 @@ +import { StoreMutatorIdentifier } from 'zustand'; + +import { + TCreatedStoreType, + TEqualityChecker, + TGetStoreEqualityRecord, + TGetStoreRecord, + TSetStoreRecord, + TStoreSelectorType, +} from './utils'; + +export type TSelectorBuilder< + TName, + StateType, + Mutators extends [StoreMutatorIdentifier, unknown][] = [], + TActions = {}, + TSelectors = {}, +> = ( + state: StateType, + get: TStoreApiGet, + api: TStateApi +) => any; + +export type TActionBuilder< + TName, + StateType, + Mutators extends [StoreMutatorIdentifier, unknown][] = [], + TActions = {}, + TSelectors = {}, +> = ( + set: TStoreApiSet, + get: TStoreApiGet, + api: TStateApi +) => any; + +export type TStoreApiGet< + StateType, + Mutators extends [StoreMutatorIdentifier, unknown][] = [], + TSelectors = {}, +> = TGetStoreRecord & + TSelectors & { + state: TCreatedStoreType['getState']; + }; + +export type TStoreApiSet< + StateType, + Mutators extends [StoreMutatorIdentifier, unknown][] = [], + TActions = {}, +> = TSetStoreRecord & + TActions & { + state: TCreatedStoreType['setState']; + }; + +export type TStateApi< + TName, + StateType, + Mutators extends [StoreMutatorIdentifier, unknown][] = [], + TActions = {}, + TSelectors = {}, +> = { + name: TName; + getInitialState: TCreatedStoreType['getInitialState']; + get: TStoreApiGet; + set: TStoreApiSet; + store: TCreatedStoreType; + useStore: ( + selector: TStoreSelectorType, + equalityFn?: TEqualityChecker + ) => FilteredStateType; + use: TGetStoreEqualityRecord & TSelectors; + useTracked: TGetStoreRecord & TSelectors; + useTrackedStore: () => StateType; + extendSelectors< + SelectorBuilder extends TSelectorBuilder< + TName, + StateType, + Mutators, + TActions, + TSelectors + >, + >( + builder: SelectorBuilder + ): TStateApi< + TName, + StateType, + Mutators, + TStoreApiSet, + TSelectors & ReturnType + >; + extendActions< + ActionBuilder extends TActionBuilder< + TName, + StateType, + Mutators, + TActions, + TSelectors + >, + >( + builder: ActionBuilder + ): TStateApi< + TName, + StateType, + Mutators, + TActions & ReturnType, + TStoreApiGet + >; +}; diff --git a/packages/zustand-x/src/types/utils.ts b/packages/zustand-x/src/types/utils.ts new file mode 100644 index 0000000..90dd234 --- /dev/null +++ b/packages/zustand-x/src/types/utils.ts @@ -0,0 +1,40 @@ +import { + Mutate, + StateCreator, + StoreApi, + StoreMutatorIdentifier, +} from 'zustand'; + +export type TEqualityChecker = ( + state: StateType, + newState: StateType +) => boolean; + +export type TGetStoreRecord = { + [K in keyof O]: () => O[K]; +}; +export type TGetStoreEqualityRecord = { + [K in keyof O]: (equalityFn?: TEqualityChecker) => O[K]; +}; +export type TSetStoreRecord = { + [K in keyof O]: (value: O[K]) => void; +}; +export type TStoreSelectorType = ( + state: StateType +) => FilteredStateType; + +export type TStoreMiddlewareStateCreatorType< + StateType, + Mps extends [StoreMutatorIdentifier, unknown][] = [], + Mutators extends [StoreMutatorIdentifier, unknown][] = [], +> = StateCreator; + +export type TCreatedStoreType< + StateType, + Mutators extends [StoreMutatorIdentifier, unknown][] = [], +> = Mutate, [...Mutators]>; + +export type TReadonlyStoreApi = Pick< + StoreApi, + 'getState' | 'getInitialState' | 'subscribe' +>; diff --git a/packages/zustand-x/src/utils/generateStateActions.ts b/packages/zustand-x/src/utils/generateStateActions.ts index b727196..fcc60a9 100644 --- a/packages/zustand-x/src/utils/generateStateActions.ts +++ b/packages/zustand-x/src/utils/generateStateActions.ts @@ -1,20 +1,25 @@ -import { TCreatedStoreType, TSetRecord } from '../types'; +import { StoreMutatorIdentifier } from 'zustand'; -export const generateStateActions = ( - store: TCreatedStoreType, +import { TCreatedStoreType, TSetStoreRecord } from '../types'; + +export const generateStateActions = < + StateType, + Middlewares extends [StoreMutatorIdentifier, unknown][] = [], +>( + store: TCreatedStoreType, storeName: string ) => { - const actions: TSetRecord = {} as TSetRecord; + const actions: TSetStoreRecord = {} as TSetStoreRecord; Object.keys(store.getState() || {}).forEach((key) => { - actions[key as keyof T] = (value) => { - const prevValue = store.getState()[key as keyof T]; + actions[key as keyof StateType] = (value) => { + const prevValue = store.getState()[key as keyof StateType]; if (prevValue === value) return; const actionKey = key.replace(/^\S/, (s) => s.toUpperCase()); store.setState( (state) => { - state[key as keyof T] = value; + state[key as keyof StateType] = value; return state; }, undefined, diff --git a/packages/zustand-x/src/utils/generateStateGetSelectors.ts b/packages/zustand-x/src/utils/generateStateGetSelectors.ts index f79e420..0484aff 100644 --- a/packages/zustand-x/src/utils/generateStateGetSelectors.ts +++ b/packages/zustand-x/src/utils/generateStateGetSelectors.ts @@ -1,10 +1,14 @@ -import { TGetSelectorRecord, TReadonlyStoreApi } from '../types'; +import { TGetStoreRecord, TReadonlyStoreApi } from '../types'; -export const generateStateGetSelectors = (store: TReadonlyStoreApi) => { - const selectors: TGetSelectorRecord = {} as TGetSelectorRecord; +export const generateStateGetSelectors = ( + store: TReadonlyStoreApi +) => { + const selectors: TGetStoreRecord = + {} as TGetStoreRecord; Object.keys(store.getState() || {}).forEach((key) => { - selectors[key as keyof T] = () => store.getState()[key as keyof T]; + selectors[key as keyof StateType] = () => + store.getState()[key as keyof StateType]; }); return selectors; diff --git a/packages/zustand-x/src/utils/generateStateHookSelectors.ts b/packages/zustand-x/src/utils/generateStateHookSelectors.ts index 0986816..a7efac6 100644 --- a/packages/zustand-x/src/utils/generateStateHookSelectors.ts +++ b/packages/zustand-x/src/utils/generateStateHookSelectors.ts @@ -1,22 +1,30 @@ +import { StoreMutatorIdentifier } from 'zustand'; + import { TCreatedStoreType, TEqualityChecker, - TGetRecord, + TGetStoreEqualityRecord, TStoreSelectorType, } from '../types'; -export const generateStateHookSelectors = ( +export const generateStateHookSelectors = < + StateType, + Middlewares extends [StoreMutatorIdentifier, unknown][] = [], +>( useStore: ( - selector: TStoreSelectorType, + selector: TStoreSelectorType, equalityFn?: TEqualityChecker ) => R, - store: TCreatedStoreType + store: TCreatedStoreType ) => { - const selectors: TGetRecord = {} as TGetRecord; + const selectors: TGetStoreEqualityRecord = + {} as TGetStoreEqualityRecord; Object.keys(store.getState() || {}).forEach((key) => { - selectors[key as keyof T] = (equalityFn?: TEqualityChecker) => { - return useStore((state) => state[key as keyof T], equalityFn); + selectors[key as keyof StateType] = ( + equalityFn?: TEqualityChecker + ) => { + return useStore((state) => state[key as keyof StateType], equalityFn); }; }); diff --git a/packages/zustand-x/src/utils/generateStateTrackedHooksSelectors.ts b/packages/zustand-x/src/utils/generateStateTrackedHooksSelectors.ts index 0adbf9b..fd67b01 100644 --- a/packages/zustand-x/src/utils/generateStateTrackedHooksSelectors.ts +++ b/packages/zustand-x/src/utils/generateStateTrackedHooksSelectors.ts @@ -1,14 +1,15 @@ -import { TGetSelectorRecord, TReadonlyStoreApi } from '../types'; +import { TGetStoreRecord, TReadonlyStoreApi } from '../types'; -export const generateStateTrackedHooksSelectors = ( - useTrackedStore: () => T, - store: TReadonlyStoreApi +export const generateStateTrackedHooksSelectors = ( + useTrackedStore: () => StateType, + store: TReadonlyStoreApi ) => { - const selectors: TGetSelectorRecord = {} as TGetSelectorRecord; + const selectors: TGetStoreRecord = + {} as TGetStoreRecord; Object.keys(store.getState() || {}).forEach((key) => { - selectors[key as keyof T] = () => { - return useTrackedStore()[key as keyof T]; + selectors[key as keyof StateType] = () => { + return useTrackedStore()[key as keyof StateType]; }; }); From 962fc06425ed96574e07b6956194436893e7ab2b Mon Sep 17 00:00:00 2001 From: Arabinda Date: Thu, 26 Dec 2024 15:15:50 +0530 Subject: [PATCH 05/28] added tests and fixed types --- packages/zustand-x/src/createStore.ts | 108 +++++++------- .../zustand-x/src/tests/createStore.spec.ts | 114 +++++++++++++++ .../zustand-x/src/tests/useStore.spec.tsx | 137 ++++++++++++++++++ packages/zustand-x/src/types/store.ts | 14 +- packages/zustand-x/src/types/utils.ts | 18 +-- packages/zustand-x/src/utils/extendActions.ts | 21 ++- .../zustand-x/src/utils/extendSelectors.ts | 64 +++++--- .../src/utils/generateStateActions.ts | 9 +- .../src/utils/generateStateGetSelectors.ts | 11 +- .../src/utils/generateStateHookSelectors.ts | 12 +- .../generateStateTrackedHooksSelectors.ts | 11 +- packages/zustand-x/src/utils/storeFactory.ts | 21 +++ 12 files changed, 429 insertions(+), 111 deletions(-) create mode 100644 packages/zustand-x/src/tests/createStore.spec.ts create mode 100644 packages/zustand-x/src/tests/useStore.spec.tsx create mode 100644 packages/zustand-x/src/utils/storeFactory.ts diff --git a/packages/zustand-x/src/createStore.ts b/packages/zustand-x/src/createStore.ts index 786c596..352cafb 100644 --- a/packages/zustand-x/src/createStore.ts +++ b/packages/zustand-x/src/createStore.ts @@ -3,26 +3,27 @@ import { createStore as createStoreZustand } from 'zustand'; import { devtools as devToolsMiddleware, DevtoolsOptions, +} from 'zustand/middleware/devtools'; +import { immer as immerMiddleware } from 'zustand/middleware/immer'; +import { persist as persistMiddleware, PersistOptions, -} from 'zustand/middleware'; +} from 'zustand/middleware/persist'; import { useStoreWithEqualityFn } from 'zustand/traditional'; import { - TActionBuilder, TEqualityChecker, - TSelectorBuilder, TStateApi, - TStoreMiddlewareStateCreatorType, - TStoreSelectorType, + TStoreInitiatorType, + TUseStoreSelectorType, } from './types'; -import { extendActions, extendSelectors } from './utils'; import { generateStateActions } from './utils/generateStateActions'; import { generateStateGetSelectors } from './utils/generateStateGetSelectors'; import { generateStateHookSelectors } from './utils/generateStateHookSelectors'; import { generateStateTrackedHooksSelectors } from './utils/generateStateTrackedHooksSelectors'; +import { storeFactory } from './utils/storeFactory'; -import type { StateCreator, StoreMutatorIdentifier } from 'zustand'; +import type { StoreMutatorIdentifier } from 'zustand'; type TCreateStoreOptions = { persist?: Partial> & { @@ -31,34 +32,64 @@ type TCreateStoreOptions = { devtools?: Partial & { enabled?: boolean; }; + immer?: { + enabled?: boolean; + }; }; -type TStoreMiddlewares = [ - ['zustand/devtools', never], - ['zustand/persist', StateType], + +type DefaultMutators< + StateType, + Options extends TCreateStoreOptions, +> = [ + ...(Options['devtools'] extends { enabled: true } + ? [['zustand/devtools', never]] + : []), + ...(Options['persist'] extends { enabled: true } + ? [['zustand/persist', StateType]] + : []), + ...(Options['immer'] extends { enabled: true } + ? [['zustand/immer', never]] + : []), ]; + +type ResolveMutators< + StateType, + Options extends TCreateStoreOptions, + Mcs extends [StoreMutatorIdentifier, unknown][], +> = [...DefaultMutators, ...Mcs]; + export const createStore = (name: TName) => < StateType, Mps extends [StoreMutatorIdentifier, unknown][] = [], Mcs extends [StoreMutatorIdentifier, unknown][] = [], + Options extends + TCreateStoreOptions = TCreateStoreOptions, + Mutators extends [StoreMutatorIdentifier, unknown][] = ResolveMutators< + StateType, + Options, + Mcs + >, >( - createState: StateCreator, - options: TCreateStoreOptions = {} + createState: TStoreInitiatorType, + options: Options = {} as Options ) => { - const { devtools, persist } = options; + const { devtools, persist, immer } = options; const middlewares: (( - initializer: StateCreator - ) => StateCreator)[] = []; + initializer: TStoreInitiatorType + ) => TStoreInitiatorType)[] = []; - if (devtools?.enabled) { + //enable devtools + if (devtools && devtools.enabled) { middlewares.push((config) => - devToolsMiddleware(config, { ...devtools, name }) + devToolsMiddleware(config, { ...devtools, name: devtools.name ?? name }) ); } - if (persist?.enabled) { + //enable persist + if (persist && persist.enabled) { middlewares.push((config) => persistMiddleware(config, { ...persist, @@ -66,18 +97,23 @@ export const createStore = }) ); } - type Mutators = [...TStoreMiddlewares, ...Mcs]; + + //enable immer + if (immer && immer.enabled) { + middlewares.push(immerMiddleware); + } + const stateMutators = middlewares.reduce( (y: any, fn) => fn(y), createState - ) as TStoreMiddlewareStateCreatorType; + ) as TStoreInitiatorType; const store = createStoreZustand(stateMutators); const getterSelectors = generateStateGetSelectors(store); const useStore = ( - selector: TStoreSelectorType, + selector: TUseStoreSelectorType, equalityFn?: TEqualityChecker ): FilteredStateType => useStoreWithEqualityFn(store, selector, equalityFn); @@ -114,35 +150,5 @@ export const createStore = return storeFactory(apiInternal) as TStateApi; }; -const storeFactory = < - TName, - StateType, - Mutators extends [StoreMutatorIdentifier, unknown][] = [], ->( - api: TStateApi -) => { - return { - ...api, - extendSelectors: (builder: TSelectorBuilder) => - storeFactory(extendSelectors(builder, api)), - extendActions: (builder: TActionBuilder) => - storeFactory(extendActions(builder, api)), - }; -}; - -// const test = createStore('hello')(() => ({ hey: 'aa' })) -// .extendSelectors(() => { -// return { -// selector: 'asas', -// }; -// }) -// .extendActions(() => { -// return { -// action: 'as', -// }; -// }); - -// test.set.action === "" - // Alias {@link createStore} export const createZustandStore = createStore; diff --git a/packages/zustand-x/src/tests/createStore.spec.ts b/packages/zustand-x/src/tests/createStore.spec.ts new file mode 100644 index 0000000..1888643 --- /dev/null +++ b/packages/zustand-x/src/tests/createStore.spec.ts @@ -0,0 +1,114 @@ +import { createStore } from '../createStore'; + +describe('zustandX', () => { + describe('when get', () => { + const store = createStore('repo')( + () => ({ + name: 'zustandX', + stars: 0, + }), + { + devtools: { + enabled: true, + }, + persist: { + enabled: true, + }, + immer: { + enabled: true, + }, + } + ); + it('should be', () => { + expect(store.get.name()).toEqual('zustandX'); + }); + }); + + describe('when extending actions', () => { + const store = createStore('repo')(() => ({ + name: 'zustandX', + stars: 0, + })) + .extendActions((set, get, api) => ({ + validName: (name: string) => { + set.name(name.trim()); + }, + })) + .extendActions((set, get, api) => ({ + reset: (name: string) => { + set.validName(name); + set.stars(0); + }, + })); + + it('should be', () => { + store.set.reset('test '); + + expect(store.get.state()).toEqual({ + name: 'test', + stars: 0, + }); + }); + }); + + describe('when extending selectors', () => { + const store = createStore('repo')(() => ({ + name: 'zustandX ', + stars: 0, + })) + .extendSelectors((set, get, api) => ({ + validName: () => get.name().trim(), + })) + .extendSelectors((set, get, api) => ({ + title: (prefix: string) => + `${prefix + get.validName()} with ${get.stars()} stars`, + })); + + it('should be', () => { + expect(store.get.title('Repository: ')).toBe( + 'Repository: zustandX with 0 stars' + ); + }); + }); + + describe('when set.state', () => { + const store = createStore('repo')(() => ({ + name: 'zustandX', + stars: 0, + })); + + it('should be', () => { + store.set.state((draft) => { + draft.name = 'test'; + draft.stars = 1; + return draft; + }); + + expect(store.get.state()).toEqual({ + name: 'test', + stars: 1, + }); + }); + + describe('deletes a property', () => { + it('should delete that property', () => { + const repoStore = createStore('repo')<{ + name?: string; + stars: number; + }>(() => ({ + name: 'zustandX', + stars: 0, + })); + + repoStore.set.state((draft) => { + delete draft.name; + return draft; + }); + + expect(repoStore.get.state()).toEqual({ + stars: 0, + }); + }); + }); + }); +}); diff --git a/packages/zustand-x/src/tests/useStore.spec.tsx b/packages/zustand-x/src/tests/useStore.spec.tsx new file mode 100644 index 0000000..cd33c3a --- /dev/null +++ b/packages/zustand-x/src/tests/useStore.spec.tsx @@ -0,0 +1,137 @@ +import '@testing-library/jest-dom'; + +import React from 'react'; +import { act, render, renderHook } from '@testing-library/react'; + +import { createZustandStore } from '../createStore'; + +describe('createAtomStore', () => { + describe('single provider', () => { + type MyTestStoreValue = { + name: string; + age: number; + }; + + const INITIAL_NAME = 'John'; + const INITIAL_AGE = 42; + + const initialTestStoreValue: MyTestStoreValue = { + name: INITIAL_NAME, + age: INITIAL_AGE, + }; + + const store = createZustandStore('myTestStore')( + () => initialTestStoreValue + ); + const useSelectors = () => store.use; + const actions = store.set; + const selectors = store.get; + + const ReadOnlyConsumer = () => { + const name = useSelectors().name(); + const age = useSelectors().age(); + + return ( +
+ {name} + {age} +
+ ); + }; + + const WriteOnlyConsumer = () => { + return ( + + ); + }; + + beforeEach(() => { + renderHook(() => actions.name(INITIAL_NAME)); + renderHook(() => actions.age(INITIAL_AGE)); + }); + + it('read only', () => { + const { getByText } = render(); + + expect(getByText(INITIAL_NAME)).toBeInTheDocument(); + expect(getByText(INITIAL_AGE)).toBeInTheDocument(); + }); + + it('actions', () => { + const { getByText } = render( + <> + + + + ); + expect(getByText(INITIAL_NAME)).toBeInTheDocument(); + expect(getByText(INITIAL_AGE)).toBeInTheDocument(); + + act(() => getByText('consumerSetAge').click()); + + expect(getByText(INITIAL_NAME)).toBeInTheDocument(); + expect(getByText(INITIAL_AGE + 1)).toBeInTheDocument(); + expect(store.store.getState().age).toBe(INITIAL_AGE + 1); + }); + }); + + describe('multiple unrelated stores', () => { + type MyFirstTestStoreValue = { name: string }; + type MySecondTestStoreValue = { age: number }; + + const initialFirstTestStoreValue: MyFirstTestStoreValue = { + name: 'My name', + }; + + const initialSecondTestStoreValue: MySecondTestStoreValue = { + age: 72, + }; + + const myFirstTestStoreStore = createZustandStore('myFirstTestStore')( + () => initialFirstTestStoreValue + ); + const mySecondTestStoreStore = createZustandStore('mySecondTestStore')( + () => initialSecondTestStoreValue + ); + + const FirstReadOnlyConsumer = () => { + const name = myFirstTestStoreStore.use.name(); + + return ( +
+ {name} +
+ ); + }; + + const SecondReadOnlyConsumer = () => { + const age = mySecondTestStoreStore.use.age(); + + return ( +
+ {age} +
+ ); + }; + + it('returns the value for the correct store', () => { + const { getByText } = render( + <> + + + + ); + + expect(getByText('My name')).toBeInTheDocument(); + expect(getByText(72)).toBeInTheDocument(); + }); + }); +}); diff --git a/packages/zustand-x/src/types/store.ts b/packages/zustand-x/src/types/store.ts index 7506264..dad942f 100644 --- a/packages/zustand-x/src/types/store.ts +++ b/packages/zustand-x/src/types/store.ts @@ -6,13 +6,13 @@ import { TGetStoreEqualityRecord, TGetStoreRecord, TSetStoreRecord, - TStoreSelectorType, + TUseStoreSelectorType, } from './utils'; export type TSelectorBuilder< TName, StateType, - Mutators extends [StoreMutatorIdentifier, unknown][] = [], + Mutators extends [StoreMutatorIdentifier, unknown][], TActions = {}, TSelectors = {}, > = ( @@ -24,7 +24,7 @@ export type TSelectorBuilder< export type TActionBuilder< TName, StateType, - Mutators extends [StoreMutatorIdentifier, unknown][] = [], + Mutators extends [StoreMutatorIdentifier, unknown][], TActions = {}, TSelectors = {}, > = ( @@ -35,7 +35,7 @@ export type TActionBuilder< export type TStoreApiGet< StateType, - Mutators extends [StoreMutatorIdentifier, unknown][] = [], + Mutators extends [StoreMutatorIdentifier, unknown][], TSelectors = {}, > = TGetStoreRecord & TSelectors & { @@ -44,7 +44,7 @@ export type TStoreApiGet< export type TStoreApiSet< StateType, - Mutators extends [StoreMutatorIdentifier, unknown][] = [], + Mutators extends [StoreMutatorIdentifier, unknown][], TActions = {}, > = TSetStoreRecord & TActions & { @@ -54,7 +54,7 @@ export type TStoreApiSet< export type TStateApi< TName, StateType, - Mutators extends [StoreMutatorIdentifier, unknown][] = [], + Mutators extends [StoreMutatorIdentifier, unknown][], TActions = {}, TSelectors = {}, > = { @@ -64,7 +64,7 @@ export type TStateApi< set: TStoreApiSet; store: TCreatedStoreType; useStore: ( - selector: TStoreSelectorType, + selector: TUseStoreSelectorType, equalityFn?: TEqualityChecker ) => FilteredStateType; use: TGetStoreEqualityRecord & TSelectors; diff --git a/packages/zustand-x/src/types/utils.ts b/packages/zustand-x/src/types/utils.ts index 90dd234..573369e 100644 --- a/packages/zustand-x/src/types/utils.ts +++ b/packages/zustand-x/src/types/utils.ts @@ -19,22 +19,18 @@ export type TGetStoreEqualityRecord = { export type TSetStoreRecord = { [K in keyof O]: (value: O[K]) => void; }; -export type TStoreSelectorType = ( +export type TUseStoreSelectorType = ( state: StateType ) => FilteredStateType; -export type TStoreMiddlewareStateCreatorType< +export type TStoreInitiatorType< StateType, - Mps extends [StoreMutatorIdentifier, unknown][] = [], - Mutators extends [StoreMutatorIdentifier, unknown][] = [], -> = StateCreator; + Mps extends [StoreMutatorIdentifier, unknown][], + Mutators extends [StoreMutatorIdentifier, unknown][], + Modified = StateType, +> = StateCreator; export type TCreatedStoreType< StateType, - Mutators extends [StoreMutatorIdentifier, unknown][] = [], + Mutators extends [StoreMutatorIdentifier, unknown][], > = Mutate, [...Mutators]>; - -export type TReadonlyStoreApi = Pick< - StoreApi, - 'getState' | 'getInitialState' | 'subscribe' ->; diff --git a/packages/zustand-x/src/utils/extendActions.ts b/packages/zustand-x/src/utils/extendActions.ts index 4b06037..29b0f13 100644 --- a/packages/zustand-x/src/utils/extendActions.ts +++ b/packages/zustand-x/src/utils/extendActions.ts @@ -1,14 +1,23 @@ +import { StoreMutatorIdentifier } from 'zustand'; + import { TActionBuilder, TStateApi } from '../types'; export const extendActions = < TName, StateType, + Middlewares extends [StoreMutatorIdentifier, unknown][], TActions, TSelectors, - Builder extends TActionBuilder, + Builder extends TActionBuilder< + TName, + StateType, + Middlewares, + TActions, + TSelectors + >, >( builder: Builder, - api: TStateApi + api: TStateApi ) => { const actions = builder(api.set, api.get, api); @@ -18,5 +27,11 @@ export const extendActions = < ...api.set, ...actions, }, - } as TStateApi, TSelectors>; + } as TStateApi< + TName, + StateType, + Middlewares, + TActions & ReturnType, + TSelectors + >; }; diff --git a/packages/zustand-x/src/utils/extendSelectors.ts b/packages/zustand-x/src/utils/extendSelectors.ts index 5c16313..1044709 100644 --- a/packages/zustand-x/src/utils/extendSelectors.ts +++ b/packages/zustand-x/src/utils/extendSelectors.ts @@ -1,14 +1,23 @@ +import { StoreMutatorIdentifier } from 'zustand'; + import { TSelectorBuilder, TStateApi } from '../types'; export const extendSelectors = < TName, StateType, + Middlewares extends [StoreMutatorIdentifier, unknown][], TActions, TSelectors, - Builder extends TSelectorBuilder, + Builder extends TSelectorBuilder< + TName, + StateType, + Middlewares, + TActions, + TSelectors + >, >( builder: Builder, - api: TStateApi + api: TStateApi ) => { const use = { ...api.use, @@ -22,33 +31,42 @@ export const extendSelectors = < ...api.get, }; - Object.keys(builder(api.store.getState(), api.get, api)).forEach((key) => { - //@ts-ignore - use[key] = (...args: any[]) => - api.useStore((state) => { - const selectors = builder(state, api.get, api); + Object.entries(builder(api.store.getState(), api.get, api)).forEach( + ([key, value]) => { + console.log(value, 'value'); + //@ts-ignore + use[key] = (...args: any[]) => + api.useStore((state) => { + const selectors = builder(state, api.get, api); + const selector = selectors[key]; + return selector(...args); + }); + //@ts-ignore + useTracked[key] = (...args: any[]) => { + const trackedState = api.useTrackedStore(); + const selectors = builder(trackedState, api.get, api); + const selector = selectors[key]; + return selector(...args); + }; + //@ts-ignore + get[key] = (...args: any[]) => { + const selectors = builder(api.store.getState(), api.get, api); const selector = selectors[key]; return selector(...args); - }); - //@ts-ignore - useTracked[key] = (...args: any[]) => { - const trackedState = api.useTrackedStore(); - const selectors = builder(trackedState, api.get, api); - const selector = selectors[key]; - return selector(...args); - }; - //@ts-ignore - get[key] = (...args: any[]) => { - const selectors = builder(api.store.getState(), api.get, api); - const selector = selectors[key]; - return selector(...args); - }; - }); + }; + } + ); return { ...api, get, use, useTracked, - } as TStateApi>; + } as TStateApi< + TName, + StateType, + Middlewares, + TActions, + TSelectors & ReturnType + >; }; diff --git a/packages/zustand-x/src/utils/generateStateActions.ts b/packages/zustand-x/src/utils/generateStateActions.ts index fcc60a9..7db57aa 100644 --- a/packages/zustand-x/src/utils/generateStateActions.ts +++ b/packages/zustand-x/src/utils/generateStateActions.ts @@ -4,7 +4,7 @@ import { TCreatedStoreType, TSetStoreRecord } from '../types'; export const generateStateActions = < StateType, - Middlewares extends [StoreMutatorIdentifier, unknown][] = [], + Middlewares extends [StoreMutatorIdentifier, unknown][], >( store: TCreatedStoreType, storeName: string @@ -12,14 +12,15 @@ export const generateStateActions = < const actions: TSetStoreRecord = {} as TSetStoreRecord; Object.keys(store.getState() || {}).forEach((key) => { - actions[key as keyof StateType] = (value) => { - const prevValue = store.getState()[key as keyof StateType]; + const typedKey = key as keyof StateType; + actions[typedKey] = (value) => { + const prevValue = store.getState()[typedKey]; if (prevValue === value) return; const actionKey = key.replace(/^\S/, (s) => s.toUpperCase()); store.setState( (state) => { - state[key as keyof StateType] = value; + state[typedKey] = value; return state; }, undefined, diff --git a/packages/zustand-x/src/utils/generateStateGetSelectors.ts b/packages/zustand-x/src/utils/generateStateGetSelectors.ts index 0484aff..658168d 100644 --- a/packages/zustand-x/src/utils/generateStateGetSelectors.ts +++ b/packages/zustand-x/src/utils/generateStateGetSelectors.ts @@ -1,7 +1,12 @@ -import { TGetStoreRecord, TReadonlyStoreApi } from '../types'; +import { StoreMutatorIdentifier } from 'zustand'; -export const generateStateGetSelectors = ( - store: TReadonlyStoreApi +import { TCreatedStoreType, TGetStoreRecord } from '../types'; + +export const generateStateGetSelectors = < + StateType, + Middlewares extends [StoreMutatorIdentifier, unknown][], +>( + store: TCreatedStoreType ) => { const selectors: TGetStoreRecord = {} as TGetStoreRecord; diff --git a/packages/zustand-x/src/utils/generateStateHookSelectors.ts b/packages/zustand-x/src/utils/generateStateHookSelectors.ts index a7efac6..f2efa67 100644 --- a/packages/zustand-x/src/utils/generateStateHookSelectors.ts +++ b/packages/zustand-x/src/utils/generateStateHookSelectors.ts @@ -4,17 +4,17 @@ import { TCreatedStoreType, TEqualityChecker, TGetStoreEqualityRecord, - TStoreSelectorType, + TUseStoreSelectorType, } from '../types'; export const generateStateHookSelectors = < StateType, - Middlewares extends [StoreMutatorIdentifier, unknown][] = [], + Middlewares extends [StoreMutatorIdentifier, unknown][], >( - useStore: ( - selector: TStoreSelectorType, - equalityFn?: TEqualityChecker - ) => R, + useStore: ( + selector: TUseStoreSelectorType, + equalityFn?: TEqualityChecker + ) => FilteredStateType, store: TCreatedStoreType ) => { const selectors: TGetStoreEqualityRecord = diff --git a/packages/zustand-x/src/utils/generateStateTrackedHooksSelectors.ts b/packages/zustand-x/src/utils/generateStateTrackedHooksSelectors.ts index fd67b01..ee2a181 100644 --- a/packages/zustand-x/src/utils/generateStateTrackedHooksSelectors.ts +++ b/packages/zustand-x/src/utils/generateStateTrackedHooksSelectors.ts @@ -1,8 +1,13 @@ -import { TGetStoreRecord, TReadonlyStoreApi } from '../types'; +import { StoreMutatorIdentifier } from 'zustand'; -export const generateStateTrackedHooksSelectors = ( +import { TCreatedStoreType, TGetStoreRecord } from '../types'; + +export const generateStateTrackedHooksSelectors = < + StateType, + Middlewares extends [StoreMutatorIdentifier, unknown][], +>( useTrackedStore: () => StateType, - store: TReadonlyStoreApi + store: TCreatedStoreType ) => { const selectors: TGetStoreRecord = {} as TGetStoreRecord; diff --git a/packages/zustand-x/src/utils/storeFactory.ts b/packages/zustand-x/src/utils/storeFactory.ts new file mode 100644 index 0000000..1530fdd --- /dev/null +++ b/packages/zustand-x/src/utils/storeFactory.ts @@ -0,0 +1,21 @@ +import { StoreMutatorIdentifier } from 'zustand'; + +import { TActionBuilder, TSelectorBuilder, TStateApi } from '../types'; +import { extendActions } from './extendActions'; +import { extendSelectors } from './extendSelectors'; + +export const storeFactory = < + TName, + StateType, + Mutators extends [StoreMutatorIdentifier, unknown][] = [], +>( + api: TStateApi +) => { + return { + ...api, + extendSelectors: (builder: TSelectorBuilder) => + storeFactory(extendSelectors(builder, api)), + extendActions: (builder: TActionBuilder) => + storeFactory(extendActions(builder, api)), + }; +}; From 3dd39dc77a661481e609e88245868d538feaa041 Mon Sep 17 00:00:00 2001 From: Arabinda Date: Thu, 26 Dec 2024 15:33:18 +0530 Subject: [PATCH 06/28] fix build errors --- packages/zustand-x/src/types/utils.ts | 4 ++-- packages/zustand-x/src/utils/extendActions.ts | 8 ++++---- packages/zustand-x/src/utils/extendSelectors.ts | 8 ++++---- packages/zustand-x/src/utils/generateStateActions.ts | 8 +++++--- packages/zustand-x/src/utils/generateStateGetSelectors.ts | 4 ++-- .../zustand-x/src/utils/generateStateHookSelectors.ts | 4 ++-- .../src/utils/generateStateTrackedHooksSelectors.ts | 4 ++-- 7 files changed, 21 insertions(+), 19 deletions(-) diff --git a/packages/zustand-x/src/types/utils.ts b/packages/zustand-x/src/types/utils.ts index 573369e..826e59b 100644 --- a/packages/zustand-x/src/types/utils.ts +++ b/packages/zustand-x/src/types/utils.ts @@ -28,9 +28,9 @@ export type TStoreInitiatorType< Mps extends [StoreMutatorIdentifier, unknown][], Mutators extends [StoreMutatorIdentifier, unknown][], Modified = StateType, -> = StateCreator; +> = StateCreator; export type TCreatedStoreType< StateType, Mutators extends [StoreMutatorIdentifier, unknown][], -> = Mutate, [...Mutators]>; +> = Mutate, Mutators>; diff --git a/packages/zustand-x/src/utils/extendActions.ts b/packages/zustand-x/src/utils/extendActions.ts index 29b0f13..0b7d58d 100644 --- a/packages/zustand-x/src/utils/extendActions.ts +++ b/packages/zustand-x/src/utils/extendActions.ts @@ -5,19 +5,19 @@ import { TActionBuilder, TStateApi } from '../types'; export const extendActions = < TName, StateType, - Middlewares extends [StoreMutatorIdentifier, unknown][], + Mutators extends [StoreMutatorIdentifier, unknown][], TActions, TSelectors, Builder extends TActionBuilder< TName, StateType, - Middlewares, + Mutators, TActions, TSelectors >, >( builder: Builder, - api: TStateApi + api: TStateApi ) => { const actions = builder(api.set, api.get, api); @@ -30,7 +30,7 @@ export const extendActions = < } as TStateApi< TName, StateType, - Middlewares, + Mutators, TActions & ReturnType, TSelectors >; diff --git a/packages/zustand-x/src/utils/extendSelectors.ts b/packages/zustand-x/src/utils/extendSelectors.ts index 1044709..e1f368d 100644 --- a/packages/zustand-x/src/utils/extendSelectors.ts +++ b/packages/zustand-x/src/utils/extendSelectors.ts @@ -5,19 +5,19 @@ import { TSelectorBuilder, TStateApi } from '../types'; export const extendSelectors = < TName, StateType, - Middlewares extends [StoreMutatorIdentifier, unknown][], + Mutators extends [StoreMutatorIdentifier, unknown][], TActions, TSelectors, Builder extends TSelectorBuilder< TName, StateType, - Middlewares, + Mutators, TActions, TSelectors >, >( builder: Builder, - api: TStateApi + api: TStateApi ) => { const use = { ...api.use, @@ -65,7 +65,7 @@ export const extendSelectors = < } as TStateApi< TName, StateType, - Middlewares, + Mutators, TActions, TSelectors & ReturnType >; diff --git a/packages/zustand-x/src/utils/generateStateActions.ts b/packages/zustand-x/src/utils/generateStateActions.ts index 7db57aa..98dea82 100644 --- a/packages/zustand-x/src/utils/generateStateActions.ts +++ b/packages/zustand-x/src/utils/generateStateActions.ts @@ -4,9 +4,9 @@ import { TCreatedStoreType, TSetStoreRecord } from '../types'; export const generateStateActions = < StateType, - Middlewares extends [StoreMutatorIdentifier, unknown][], + Mutators extends [StoreMutatorIdentifier, unknown][], >( - store: TCreatedStoreType, + store: TCreatedStoreType, storeName: string ) => { const actions: TSetStoreRecord = {} as TSetStoreRecord; @@ -18,8 +18,10 @@ export const generateStateActions = < if (prevValue === value) return; const actionKey = key.replace(/^\S/, (s) => s.toUpperCase()); + + //@ts-ignore store.setState( - (state) => { + (state: StateType) => { state[typedKey] = value; return state; }, diff --git a/packages/zustand-x/src/utils/generateStateGetSelectors.ts b/packages/zustand-x/src/utils/generateStateGetSelectors.ts index 658168d..2f2f4ec 100644 --- a/packages/zustand-x/src/utils/generateStateGetSelectors.ts +++ b/packages/zustand-x/src/utils/generateStateGetSelectors.ts @@ -4,9 +4,9 @@ import { TCreatedStoreType, TGetStoreRecord } from '../types'; export const generateStateGetSelectors = < StateType, - Middlewares extends [StoreMutatorIdentifier, unknown][], + Mutators extends [StoreMutatorIdentifier, unknown][], >( - store: TCreatedStoreType + store: TCreatedStoreType ) => { const selectors: TGetStoreRecord = {} as TGetStoreRecord; diff --git a/packages/zustand-x/src/utils/generateStateHookSelectors.ts b/packages/zustand-x/src/utils/generateStateHookSelectors.ts index f2efa67..d85e366 100644 --- a/packages/zustand-x/src/utils/generateStateHookSelectors.ts +++ b/packages/zustand-x/src/utils/generateStateHookSelectors.ts @@ -9,13 +9,13 @@ import { export const generateStateHookSelectors = < StateType, - Middlewares extends [StoreMutatorIdentifier, unknown][], + Mutators extends [StoreMutatorIdentifier, unknown][], >( useStore: ( selector: TUseStoreSelectorType, equalityFn?: TEqualityChecker ) => FilteredStateType, - store: TCreatedStoreType + store: TCreatedStoreType ) => { const selectors: TGetStoreEqualityRecord = {} as TGetStoreEqualityRecord; diff --git a/packages/zustand-x/src/utils/generateStateTrackedHooksSelectors.ts b/packages/zustand-x/src/utils/generateStateTrackedHooksSelectors.ts index ee2a181..06d1e37 100644 --- a/packages/zustand-x/src/utils/generateStateTrackedHooksSelectors.ts +++ b/packages/zustand-x/src/utils/generateStateTrackedHooksSelectors.ts @@ -4,10 +4,10 @@ import { TCreatedStoreType, TGetStoreRecord } from '../types'; export const generateStateTrackedHooksSelectors = < StateType, - Middlewares extends [StoreMutatorIdentifier, unknown][], + Mutators extends [StoreMutatorIdentifier, unknown][], >( useTrackedStore: () => StateType, - store: TCreatedStoreType + store: TCreatedStoreType ) => { const selectors: TGetStoreRecord = {} as TGetStoreRecord; From dda79241f65869b5881b1ea98a4f16c339e1f2b9 Mon Sep 17 00:00:00 2001 From: Arabinda Date: Thu, 26 Dec 2024 17:23:54 +0530 Subject: [PATCH 07/28] fix: all test cases --- packages/zustand-x/package.json | 3 +- packages/zustand-x/src/createStore.ts | 33 +++++-------- .../zustand-x/src/tests/createStore.spec.ts | 1 + .../zustand-x/src/tests/useStore.spec.tsx | 1 - packages/zustand-x/src/types/store.ts | 13 ++--- packages/zustand-x/src/types/utils.ts | 3 +- .../zustand-x/src/utils/extendSelectors.ts | 49 +++++++++---------- .../src/utils/generateStateActions.ts | 8 +-- .../src/utils/generateStateHookSelectors.ts | 9 +--- yarn.lock | 13 ++++- 10 files changed, 63 insertions(+), 70 deletions(-) diff --git a/packages/zustand-x/package.json b/packages/zustand-x/package.json index b81118d..7b6e102 100644 --- a/packages/zustand-x/package.json +++ b/packages/zustand-x/package.json @@ -40,7 +40,8 @@ "dependencies": { "immer": "^10.0.3", "lodash.mapvalues": "^4.6.0", - "react-tracked": "^1.7.11" + "react-tracked": "^1.7.11", + "use-sync-external-store": "1.4.0" }, "peerDependencies": { "zustand": ">=4.3.9" diff --git a/packages/zustand-x/src/createStore.ts b/packages/zustand-x/src/createStore.ts index 352cafb..bdf3a73 100644 --- a/packages/zustand-x/src/createStore.ts +++ b/packages/zustand-x/src/createStore.ts @@ -1,22 +1,14 @@ import { createTrackedSelector } from 'react-tracked'; -import { createStore as createStoreZustand } from 'zustand'; import { devtools as devToolsMiddleware, DevtoolsOptions, -} from 'zustand/middleware/devtools'; -import { immer as immerMiddleware } from 'zustand/middleware/immer'; -import { persist as persistMiddleware, PersistOptions, -} from 'zustand/middleware/persist'; -import { useStoreWithEqualityFn } from 'zustand/traditional'; +} from 'zustand/middleware'; +import { immer as immerMiddleware } from 'zustand/middleware/immer'; +import { createWithEqualityFn as createStoreZustand } from 'zustand/traditional'; -import { - TEqualityChecker, - TStateApi, - TStoreInitiatorType, - TUseStoreSelectorType, -} from './types'; +import { TStateApi, TStoreInitiatorType } from './types'; import { generateStateActions } from './utils/generateStateActions'; import { generateStateGetSelectors } from './utils/generateStateGetSelectors'; import { generateStateHookSelectors } from './utils/generateStateHookSelectors'; @@ -112,16 +104,15 @@ export const createStore = const getterSelectors = generateStateGetSelectors(store); - const useStore = ( - selector: TUseStoreSelectorType, - equalityFn?: TEqualityChecker - ): FilteredStateType => useStoreWithEqualityFn(store, selector, equalityFn); - - const stateActions = generateStateActions(store, name); + const stateActions = generateStateActions( + store, + name, + options.immer?.enabled + ); - const hookSelectors = generateStateHookSelectors(useStore, store); + const hookSelectors = generateStateHookSelectors(store); - const useTrackedStore = createTrackedSelector(useStore); + const useTrackedStore = createTrackedSelector(store); const trackedHooksSelectors = generateStateTrackedHooksSelectors( useTrackedStore, store @@ -139,7 +130,7 @@ export const createStore = ...stateActions, }, store, - useStore, + useStore: store, use: hookSelectors, useTracked: trackedHooksSelectors, useTrackedStore, diff --git a/packages/zustand-x/src/tests/createStore.spec.ts b/packages/zustand-x/src/tests/createStore.spec.ts index 1888643..075129e 100644 --- a/packages/zustand-x/src/tests/createStore.spec.ts +++ b/packages/zustand-x/src/tests/createStore.spec.ts @@ -19,6 +19,7 @@ describe('zustandX', () => { }, } ); + it('should be', () => { expect(store.get.name()).toEqual('zustandX'); }); diff --git a/packages/zustand-x/src/tests/useStore.spec.tsx b/packages/zustand-x/src/tests/useStore.spec.tsx index cd33c3a..b92caec 100644 --- a/packages/zustand-x/src/tests/useStore.spec.tsx +++ b/packages/zustand-x/src/tests/useStore.spec.tsx @@ -44,7 +44,6 @@ describe('createAtomStore', () => {