Skip to content
This repository was archived by the owner on Mar 5, 2023. It is now read-only.

Having multiple machines codegenerated breaks send autocompletion? #76

@github0013

Description

@github0013

When I only have one machine ts file like below,

// switch.machine.ts
import { Machine } from "@xstate/compiled"

interface Context {}

type Event = { type: "toggle" }

export default Machine<Context, Event, "basicSwitch">({
  context: {},
  initial: "active",
  states: {
    active: {
      on: {
        toggle: {
          target: "inactive",
        },
      },
    },
    inactive: {
      on: {
        toggle: {
          target: "active",
        },
      },
    },
  },
})

using send on react side works as expected. It shows the mismatching event name, and it autocompletes.
Screen Shot 2021-04-02 at 15 34 29

However, if I create another machine ts file, then it generates for the new one fine, but then send error message and autocompletion get disappeared.
Screen Shot 2021-04-02 at 15 36 40

send signature when works

const send: (event: SingleOrArray<Event<Event>> | SCXML.Event<Event>, payload?: EventData) => State<Context, Event, unknown, {
    ...;
}>

send signature when doesn't

const send: (event: SCXML.Event<EventObject> | SingleOrArray<Event<EventObject>>, payload?: EventData) => State<Context, EventObject, unknown, {
    ...;
}>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions