xstate-tools icon indicating copy to clipboard operation
xstate-tools copied to clipboard

Typegen: Ensure that state.matches allows for object-based checks on states with no children

Open mattpocock opened this issue 3 years ago • 4 comments

I.e. in this machine:

const machine = createMachine({
  initial: 'a',
  states: { a: {} },
})

You should be able to run:

state.matches({ a: {} })

mattpocock avatar Apr 11 '22 08:04 mattpocock

Is this desired though? It somewhat looks incomplete and/or implies that some child states can be added to it.

Andarist avatar Apr 11 '22 08:04 Andarist

Yes, because you want to be able to make parallel-based checks, like so:

https://discord.com/channels/795785288994652170/962341003266760786/962343455135264828

image

mattpocock avatar Apr 11 '22 08:04 mattpocock

Yuck 😬 I don't have a better idea though - so ye, we should support this then

Andarist avatar Apr 11 '22 09:04 Andarist

Agree; this should be supported

davidkpiano avatar Apr 11 '22 14:04 davidkpiano