#TypeGen & V5

1 messages · Page 1 of 1 (latest)

slow sigil
#

I've been seeing some conflicting information in places saying typegen is available and not available for V5 beta. Is there a way to use react/useActor in V5 beta where typescript doesnt yell at you for not manually typing all the events?

slow sigil
#

Bit confused what to do here - provided some small code snippets. I'm hoping i don't have to manually type all of these events from scratch 😅 but if that's how it is, I guess i know the time spent is required and not just me missing some snippet somewhere!

#

Oooh.. ok so as a bit of a workaround I found a temporary solution!

export const notifymeMachine =
  createMachine({
    // @ts-ignore
    tsTypes: {} as import("./notifyMe.typegen.d.ts").Typegen0,

    types: {
      typegen: {} as import("./notifyMe.typegen.d.ts").Typegen0,

using the older xstate-tools, add a tsTypes property tsTypes: {} as {} then duplicate the expansion into the typegen property inside the types object.

this seems to type the events just fine 🙂

plush peak
#

Yep, it's now in types: { typegen: ... } but as you may discover it doesn't work fully yet

slow sigil
#

No worries - this will help me get by hopefully till one day typegen is ready for v5 🙂 already really liking a lot of the new forms ☑️