Skip to content

Commit

Permalink
Update store and collection type infer
Browse files Browse the repository at this point in the history
  • Loading branch information
jozefini committed Jan 21, 2025
1 parent 11d8100 commit a0461d4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/store/src/collection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { isDeepEqual } from './store';
// =====================
// Type Helpers
// =====================

/* eslint-disable @typescript-eslint/no-explicit-any */
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
type AnyType = any;
type IsOptionalPayload<T> = unknown extends T
Expand Down Expand Up @@ -177,7 +179,10 @@ export function createCollection<
}

const keySubscribers = subscribers.byKey.get(key);
if (!keySubscribers) return () => {};
if (!keySubscribers)
return () => {
return null;
};

const id = nextSubscriberId++;
const initialSelector = selector || ((s: States) => s);
Expand Down Expand Up @@ -457,7 +462,7 @@ export function createCollection<

const [payload, shouldNotify = true] = args;
const newState = { ...state };
const result = cb(newState, payload as Actions[K]);
const result = cb(newState, payload ?? (undefined as Actions[K]));

// Handle async actions
if (result instanceof Promise) {
Expand Down
1 change: 1 addition & 0 deletions packages/store/src/store.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
// Types
// =====================

/* eslint-disable @typescript-eslint/no-explicit-any */
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
type AnyType = any;
type DevToolsMessage = {
Expand Down

0 comments on commit a0461d4

Please sign in to comment.