diff --git a/ember-statechart-component/package.json b/ember-statechart-component/package.json index b3f1981a..4828b613 100644 --- a/ember-statechart-component/package.json +++ b/ember-statechart-component/package.json @@ -55,7 +55,7 @@ }, "peerDependencies": { "@glint/template": ">= 0.8.3", - "xstate": "^4.30.0" + "xstate": "^4.32.1" }, "peerDependenciesMeta": { "@glint/template": { diff --git a/ember-statechart-component/src/glint.ts b/ember-statechart-component/src/glint.ts index a566439b..3e9cb5fe 100644 --- a/ember-statechart-component/src/glint.ts +++ b/ember-statechart-component/src/glint.ts @@ -1,31 +1,33 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ import type { ComponentLike } from '@glint/template'; import type { + AnyStateMachine, ContextFrom, - createMachine, EventFrom, Interpreter, MachineConfig, + StateFrom, + StateMachine, StateSchema, } from 'xstate'; +type StateSchemaFrom = T extends StateMachine ? U : StateSchema; + export type State = Interpreter>['state']; export type Send = Interpreter>['send']; export type OnTransition = Interpreter>['onTransition']; -// eslint-disable-next-line @typescript-eslint/no-explicit-any -export type MachineComponent = any> = ComponentLike<{ +export type MachineComponent = ComponentLike<{ Args: { - config?: MachineConfig, StateSchema, EventFrom>; - context?: State['context']; - state?: State; + config?: MachineConfig, StateSchemaFrom, EventFrom>; + context?: StateFrom['context']; + state?: StateFrom; }; Blocks: { default: [State, Send, OnTransition]; }; }>; -export function asComponent( - machine: T -): MachineComponent> { - return machine as unknown as MachineComponent>; +export function asComponent(machine: T): MachineComponent { + return machine as unknown as MachineComponent; }