diff --git a/packages/xstate-graph/src/graph.ts b/packages/xstate-graph/src/graph.ts index 8c98ded8a1..d78cfd946c 100644 --- a/packages/xstate-graph/src/graph.ts +++ b/packages/xstate-graph/src/graph.ts @@ -88,7 +88,7 @@ export function createDefaultMachineOptions( serializeEvent, events: (state) => { const events = - typeof getEvents === 'function' ? getEvents(state) : getEvents ?? []; + typeof getEvents === 'function' ? getEvents(state) : (getEvents ?? []); return __unsafe_getAllOwnEventDescriptors(state).flatMap((type) => { const matchingEvents = events.filter((ev) => (ev as any).type === type); if (matchingEvents.length) { @@ -128,7 +128,7 @@ export function toDirectedGraph( return targets.map((target, targetIndex) => { const edge: DirectedGraphEdge = { id: `${stateNode.id}:${transitionIndex}:${targetIndex}`, - source: stateNode as AnyStateNode, + source: stateNode, target: target as AnyStateNode, transition: t, label: { @@ -148,8 +148,8 @@ export function toDirectedGraph( const graph = { id: stateNode.id, - stateNode: stateNode as AnyStateNode, - children: getChildren(stateNode as AnyStateNode).map(toDirectedGraph), + stateNode: stateNode, + children: getChildren(stateNode).map(toDirectedGraph), edges, toJSON: () => { const { id, children, edges: graphEdges } = graph; diff --git a/packages/xstate-store/src/react.ts b/packages/xstate-store/src/react.ts index a445c49405..306221bcbb 100644 --- a/packages/xstate-store/src/react.ts +++ b/packages/xstate-store/src/react.ts @@ -1,5 +1,5 @@ import { useCallback, useRef, useSyncExternalStore } from 'react'; -import { Store, SnapshotFromStore, AnyStore } from './types'; +import { SnapshotFromStore, AnyStore } from './types'; function defaultCompare(a: T | undefined, b: T) { return a === b; diff --git a/packages/xstate-store/src/solid.ts b/packages/xstate-store/src/solid.ts index 7e2f779bf0..05bcd65904 100644 --- a/packages/xstate-store/src/solid.ts +++ b/packages/xstate-store/src/solid.ts @@ -1,6 +1,6 @@ /* @jsxImportSource solid-js */ import { createEffect, createSignal, onCleanup } from 'solid-js'; -import type { Store, SnapshotFromStore, AnyStore } from './types'; +import type { SnapshotFromStore, AnyStore } from './types'; function defaultCompare(a: T | undefined, b: T) { return a === b; diff --git a/packages/xstate-store/src/store.ts b/packages/xstate-store/src/store.ts index 3b1acd1487..41ddb38c7d 100644 --- a/packages/xstate-store/src/store.ts +++ b/packages/xstate-store/src/store.ts @@ -131,7 +131,7 @@ function createStoreCore< return { unsubscribe() { - eventListeners!.delete(wrappedHandler); + eventListeners.delete(wrappedHandler); } }; }, @@ -434,16 +434,10 @@ export function createStoreTransition< if (typeof assigner === 'function') { currentContext = updater - ? updater( - currentContext, - (draftContext) => - ( - assigner as StoreCompleteAssigner< - TContext, - StoreEvent, - TEmitted - > - )?.(draftContext, event, enqueue) + ? updater(currentContext, (draftContext) => + ( + assigner as StoreCompleteAssigner + )?.(draftContext, event, enqueue) ) : setter(currentContext, (draftContext) => Object.assign( diff --git a/packages/xstate-store/src/types.ts b/packages/xstate-store/src/types.ts index 9e36ed2ea6..78d60ae7dd 100644 --- a/packages/xstate-store/src/types.ts +++ b/packages/xstate-store/src/types.ts @@ -109,7 +109,7 @@ export interface Store< export type AnyStore = Store; -export type Compute = { [K in keyof A]: A[K] } & unknown; +export type Compute = { [K in keyof A]: A[K] }; export type SnapshotFromStore> = TStore extends Store