diff --git a/src/Updux.ts b/src/Updux.ts index ffa5084..a776021 100644 --- a/src/Updux.ts +++ b/src/Updux.ts @@ -25,6 +25,8 @@ export type DuxStateSubduxes = keyof C extends never ? unknown : { [K in keyof C]: StateOf }; +type DuxAggregateState = TState & DuxStateSubduxes ; + export class Updux { #localInitial: any = {}; #subduxes; @@ -41,7 +43,7 @@ export class Updux { + get initial(): DuxAggregateState{ if (Object.keys(this.#subduxes).length === 0) return this.#localInitial; return Object.assign( @@ -52,6 +54,6 @@ export class Updux state; + return (state : DuxAggregateState, _action : any) => state; } } diff --git a/src/reducer.test.ts b/src/reducer.test.ts index 82a1e15..838247e 100644 --- a/src/reducer.test.ts +++ b/src/reducer.test.ts @@ -3,7 +3,7 @@ import { test, expect } from 'vitest'; import { Updux } from './Updux.js'; test('basic reducer', () => { - const dux = new Updux({}); + const dux = new Updux({ initial: {a: 3} }); expect(dux.reducer).toBeTypeOf('function');