Skip to content

Bug: Durations defined in setup() are not strongly typed #5375

@nicosampler

Description

@nicosampler

XState version

XState version 5

Description

According to the documentation, durations can be typed if they are defined in the setup. This is not working for me.

Expected result

I would expect it to be typed.

Actual result

As you can see in the image, I would expect the value in states.sleep.after.slotDuration222 to be marked as a TS error.

Image

Also, if I run it with the value key slotDuration222 it is not even detected as an error and the machine instantly transitions to the target. If the value provided is undefined, shouldn't it be expected to fail?

Reproduction

https://codesandbox.io/p/sandbox/9n6lym

Additional context

for some reason, the example erases this chunk of code in the setup:

delays: {
    someDelay: 10000,
  },

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions