xstate: Version 4.23.0 breaks typing of "$" prefixed service inside svelte component
Given this
const machine = model.createMachine(...)
const service = interpret(machine).start();
Until 4.22
const { someData } = $service.context // This returns the correct type
From 4.23.0
service.subscribe((state) => {
state.context // This still returns a correct type
})
const { someData } = $service.context // $service becomes any
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 2
- Comments: 22 (17 by maintainers)
I think the tag
@xstate/svelteis inaccurate here, this issue is caused by the typing change in thecoreand there is nothing to do with@xstate/svelte.But I’d say severity of this issue has dropped significantly by the introduction of
useSelectorto@xstate/svelte. I’m pretty positive that one should always prefer usinguseSelectorinstead of direct access with$.