statelyai / xstate-tools

Public monorepo for XState tooling
183 stars 36 forks source link

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

Open mattpocock opened 2 years ago

mattpocock commented 2 years ago

I.e. in this machine:

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

You should be able to run:

state.matches({ a: {} })

Andarist commented 2 years ago

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

mattpocock commented 2 years ago

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

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

image

Andarist commented 2 years ago

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

davidkpiano commented 2 years ago

Agree; this should be supported