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: 5.17.0 Property "(machine)" is missing in type... #5008

Closed
wKovacs64 opened this issue Jul 30, 2024 · 0 comments · Fixed by #5009
Closed

Bug: 5.17.0 Property "(machine)" is missing in type... #5008

wKovacs64 opened this issue Jul 30, 2024 · 0 comments · Fixed by #5009
Labels

Comments

@wKovacs64
Copy link
Contributor

XState version

XState version 5

Description

Hey folks. Getting a type error in xstate v5.17.0 when passing a few of my machines to useMachine from @xstate/react, but not all of them - can't quite figure out what's different enough between them to nail down the culprit. Is it obvious to you based on this error?

image

Expected result

No type errors.

Actual result

Argument of type 'StateMachine<CheatCodeContext, KeydownEvent, {}, never, Values<{ record: { type: "record"; params: NonReducibleUnknown; }; resetTypedKeys: { ...; }; }>, ... 8 more ..., { ...; }>' is not assignable to parameter of type 'AnyStateMachine'.
  The types returned by 'resolveState(...)' are incompatible between these types.
    Type 'MachineSnapshot<CheatCodeContext, KeydownEvent, {}, { disabled?: "idle" | "recording" | undefined; enabled?: "idle" | "recording" | undefined; }, string, NonReducibleUnknown, MetaObject, { ...; }>' is not assignable to type 'MachineSnapshot<any, any, any, any, any, any, any, StateSchema>'.
      Type 'ActiveMachineSnapshot<CheatCodeContext, KeydownEvent, {}, { disabled?: "idle" | "recording" | undefined; enabled?: "idle" | "recording" | undefined; }, string, NonReducibleUnknown, MetaObject, { ...; }>' is not assignable to type 'MachineSnapshot<any, any, any, any, any, any, any, StateSchema>'.
        Type 'ActiveMachineSnapshot<CheatCodeContext, KeydownEvent, {}, { disabled?: "idle" | "recording" | undefined; enabled?: "idle" | "recording" | undefined; }, string, NonReducibleUnknown, MetaObject, { ...; }>' is not assignable to type 'ActiveMachineSnapshot<any, any, any, any, any, any, any, StateSchema>'.
          The types returned by 'getMeta()' are incompatible between these types.
            Property '"(machine)"' is missing in type 'Record<"cheatCodeMachine" | "cheatCodeMachine.disabled" | "cheatCodeMachine.disabled.idle" | "cheatCodeMachine.disabled.recording" | "cheatCodeMachine.enabled" | "cheatCodeMachine.enabled.idle" | "cheatCodeMachine.enabled.recording", MetaObject | undefined>' but required in type 'Record<"(machine)", any>'.ts(2345)

Reproduction

https://github.com/wKovacs64/use-secret-code/blob/074b6fa0aadf7abd21edcffe3a4ea040f64200bb/src/index.ts

Additional context

Happy to provide more info if needed, but this feels like something you're going to eyeball and know right away. 🙂 Thanks.

@wKovacs64 wKovacs64 added the bug label Jul 30, 2024
@davidkpiano davidkpiano linked a pull request Jul 31, 2024 that will close this issue
davidkpiano added a commit that referenced this issue Jul 31, 2024
* Add failing test

* Merge

* Make all StateMachine type params required

* Changeset?

* Update packages/core/src/types.ts

* Don't need the any check after all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant