statelyai / xstate

Actor-based state management & orchestration for complex app logic.
https://stately.ai/docs
MIT License
27.18k stars 1.26k forks source link

Bug: `@xstate/vue` has wrong typings for `useMachine` #3662

Closed TheDutchCoder closed 2 years ago

TheDutchCoder commented 2 years ago

Description

useMachine requires 2 parameters when using @xstate/vue, however that should just be one (options is optional).

xstate source: https://github.com/statelyai/xstate/blob/main/packages/core/src/interpreter.ts#L308 @xstate/vue source: https://github.com/statelyai/xstate/blob/main/packages/xstate-vue/src/useMachine.ts#L50

Expected result

Not to have to pass a required options argument

Actual result

Requires an options argument Example: const { state, send } = useMachine(machine, {})

Reproduction

N/A (Typescript issue)

Additional context

No response

Andarist commented 2 years ago

Please always try to share a repro case in a runnable form - either by providing a git repository to clone or a codesandbox. OSS maintainers usually can't afford the time to set up the repro, even if exact steps are given.

TheDutchCoder commented 2 years ago

I can no longer reproduce this with a simple example. It might be a Vite caching problem (older version or something), or a typegen issue on the machine.

I will re-open if I run into it again and can isolate the case.