Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: import-paste auto-edits malformed machines #237

Open
tomByrer opened this issue May 31, 2024 · 0 comments
Open

Bug: import-paste auto-edits malformed machines #237

tomByrer opened this issue May 31, 2024 · 0 comments

Comments

@tomByrer
Copy link

Issue: Studio automatically 'fixes' (not really) bad machines, with no warnings.

1: paste in this broken machine:

import { createMachine } from "xstate";

export const machinebuglonefinaloutside = createMachine({
	id: "bug-lone-final-outside",
	initial: "Inner",
	states: {
		Inner: {
			id: "",
			initial: "choose",
			states: {
				choose: {
					on: {
						"choose--endInner": {
							target: "endInner"
						},
						"choose--endRoot": {
							target: "endRoot" //<== error
						}
					}
				},
				endInner: {
					type: "final"
				}
			}
		},
		endRoot: {
			type: "final"
		}
	}
},);
  1. this is what studio has after paste
import { setup } from "xstate";

export const machine = setup({
  types: {
    context: {} as {},
    events: {} as { type: "choose--endInner" } | { type: "choose--endRoot" },
  },
}).createMachine({
  context: {},
  id: "bug-lone-final-outside",
  initial: "Inner",
  states: {
    Inner: {
      initial: "choose",
      states: {
        choose: {
          on: {
            "choose--endInner": {
              target: "endInner",
            },
            "choose--endRoot": {}, //<== the 'fix'
          },
        },
        endInner: {
          type: "final",
        },
      },
    },
    endRoot: {
      type: "final",
    },
  },
});

Expected:
Some warning somewhere, comment in code, popup like in vis, or am I missing the error warning?
image


Studio version: 0.125.0

@tomByrer tomByrer changed the title import-paste auto-edits malformed machines Bug: import-paste auto-edits malformed machines May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant