diff --git a/core/src/index.ts b/core/src/index.ts index 3192a229..a2550bca 100644 --- a/core/src/index.ts +++ b/core/src/index.ts @@ -71,7 +71,10 @@ function emitCreated(store: InternalStore, state: any): void { eventEmitter.once(EVENTS.core.installed, created); } -function getExtendedStore[]>(store: InternalStore, extensions: TExtensions): ReturnType> { +function getExtendedStore[]>( + store: InternalStore, + extensions: TExtensions +): ReturnType> { return extensions.reduce((output, extension) => { let result = {}; @@ -114,7 +117,7 @@ function installPlugin(plugin: HarlemPlugin, app: App): void { export const on = eventEmitter.on.bind(eventEmitter); export const once = eventEmitter.once.bind(eventEmitter); -export function createStore[]>( +export function createStore[] = []>( name: string, state: TState, options?: Partial> diff --git a/core/src/types.ts b/core/src/types.ts index e296323f..a65072f9 100644 --- a/core/src/types.ts +++ b/core/src/types.ts @@ -6,7 +6,6 @@ import type { type UnionToIntersection = (TValue extends any ? (arg: TValue) => any : never) extends ((arg: infer I) => void) ? I : never; -//export type BaseState = object; export type BaseState = Record; export type StoreProvider = keyof StoreProviders; export type ReadState = DeepReadonly; @@ -23,11 +22,10 @@ export type EventHandler = (payload?: EventPayload) => void; export type TriggerHandler = (data: TEventData) => void; export type Trigger = (name: string | string[], handler: TriggerHandler) => EventListener; export type BranchAccessor = (state: ReadState | WriteState) => TBranchState; -export type InternalStores = Map>; +export type InternalStores = Map>; export type Extension = (store: InternalStore) => Record; -export type ExtensionAPIs[]> = UnionToIntersection>; -export type PublicStore[]> = Store & ExtensionAPIs; -// export type PublicStore[]> = Omit, keyof ExtensionAPIs> & ExtensionAPIs +export type ExtensionAPIs[]> = UnionToIntersection>; +export type PublicStore[]> = Omit, keyof ExtensionAPIs> & ExtensionAPIs export interface Emittable { on(event: string, handler: EventHandler): EventListener; @@ -158,7 +156,7 @@ export interface StoreProviders { payload(payload: TPayload): TPayload; } -export interface InternalStore extends StoreBase { +export interface InternalStore extends StoreBase { /** * A boolean indicating whether this store allows overwriting duplicate registrations */ diff --git a/core/test/index.test.ts b/core/test/index.test.ts index 84bb45a4..c92224d7 100644 --- a/core/test/index.test.ts +++ b/core/test/index.test.ts @@ -8,7 +8,9 @@ import Harlem, { } from '../src'; import { + App, isRef, + Plugin, ref, } from 'vue'; @@ -46,12 +48,6 @@ function getStore() { [internalKey]: 10, }, { allowOverwrite: false, - // extensions: [ - // store => ({ - // blah: 5, - // //action: () => 6 - // }), - // ], }); const fullName = getter('fullname', ({ details }) => `${details.firstName} ${details.lastName}`); @@ -88,12 +84,12 @@ describe('Harlem Core', () => { beforeAll(() => { const app = { - use: (plugin: any, options?: any) => { + use: (plugin: Plugin, options?: any) => { if (plugin && plugin.install){ plugin.install(app, options); } }, - }; + } as App; app.use(Harlem); });