statelyai / xstate-tools

Public monorepo for XState tooling
183 stars 40 forks source link

Bug: VSCode plugin error "<action> is never used in the machine definition" #373

Open jluxenberg opened 1 year ago

jluxenberg commented 1 year ago

Description

Consider this machine definition:

import { createMachine, assign } from 'xstate';

export const machine = 
  createMachine(
    {
      tsTypes: {} as import("./machine.typegen").Typegen0,
      id: 'machine',
      initial: 'initial',
      states: {
        initial: {
          entry: [{type: 'action1'}],
        },
      },
      predictableActionArguments: true,
      preserveActionOrder: true,
    },
    {
      actions: {
        action1: (_, event) => {
            console.log("action1", event);
        },
      },
    },
  );

Expected result

I expected to see no errors; the plugin should be aware of the use of action1.

Actual result

I get an error on line 19 "action1 is never used in the machine definition":

CleanShot 2023-09-27 at 14 49 41

Reproduction

N/A ; only occurs in the VSCode plugin

Additional context

No response

Jordan-Eckowitz commented 11 months ago

I'm seeing something similar with guards. When I changed the guarded transition key from cond to guard as a part of the v5 migration it now always shows guards as unused.

ref: https://stately.ai/docs/migration#guarded-transitions-use-guard-not-cond

davidkpiano commented 11 months ago

I'm seeing something similar with guards. When I changed the guarded transition key from cond to guard as a part of the v5 migration it now always shows guards as unused.

ref: https://stately.ai/docs/migration#guarded-transitions-use-guard-not-cond

We still need to update the extension to be v5-aware; that's in progress (cc. @farskid @Andarist)

nadavhalfon commented 10 months ago

Oh Ok, do you have any schedule for that? (even an estimation)?