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: fromPromise is not imported from "xstate" on code generation #228

Closed
egorFiNE opened this issue Mar 25, 2024 · 2 comments
Closed

Bug: fromPromise is not imported from "xstate" on code generation #228

egorFiNE opened this issue Mar 25, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@egorFiNE
Copy link

Description

Steps:

  1. Create an empty state machine with a single state.
  2. Add an invocation of "invoke1" into a state.
  3. Click on "<> Code" tab. Choose JavaScript and XState v5.

Expected result

import { createMachine, fromPromise } from "xstate"; // Notice: fromPromise should be imported
export const machine = createMachine(
// ...
    actors: {
      invoke1: fromPromise({
        /* ... */
      })
// ...

Actual result

import { createMachine } from "xstate";
export const machine = createMachine(
// ...
    actors: {
      invoke1: fromPromise({
        /* ... */
      })
// ...

Which browsers are you seeing the problem on?

No response

Additional details

This is a trivial and minor bug that makes it impossible to blindly copy-paste the generated code into a file in project.

Also, code generation for TypeScript is a bit broken the same way, too.

@egorFiNE egorFiNE added the bug Something isn't working label Mar 25, 2024
@davidkpiano
Copy link
Member

I can't quite reproduce this. Is this what you are doing?

CleanShot.2024-03-27.at.22.09.57.mp4

@egorFiNE
Copy link
Author

Yeah my bad, I can't reproduce it. Seems like I messed up with export/import code or something so that there is a "fromPromise" in actual code, but there isn't a flag to add this function to imports.

I will reopen if I reproduce it cleanly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants