xstate-tools icon indicating copy to clipboard operation
xstate-tools copied to clipboard

Cannot load a machine inside a file which contains decorator syntax

Open BrunoUY opened this issue 2 years ago • 4 comments

Hi, I can´t open a machine defined inside a .tsx file; it's possible?

I'm using stencilJS and the components get the .tsx extension

thanks!

BrunoUY avatar Oct 12 '21 20:10 BrunoUY

Could you make a reproduction? I can load them from within .tsx files fine locally. What version are you on?

mattpocock avatar Oct 12 '21 20:10 mattpocock

Hi, I uploaded it here

https://github.com/BrunoUY/test-xstate-visualizer

I'm trying to open it in https://github.com/BrunoUY/test-xstate-visualizer/blob/master/src/components/app-payment-form/app-payment-form.tsx

line 5

as the "open inspector" text don´t appear I used the command "XState: open inspector" and I got the message "could not find a machine at the current cursor"

I put another machine on https://github.com/BrunoUY/test-xstate-visualizer/blob/master/src/helpers/promise-machine.ts and this one got the "open inspector" button on the editor without a problem

BrunoUY avatar Oct 12 '21 20:10 BrunoUY

Thanks - looks legit, I tested it and it fails. It looks like it doesn't like the decorator syntax used there, which is annoying because I've fixed that before.

For now, define your machine in a separate file to the decorator syntax and it'll work.

mattpocock avatar Oct 12 '21 20:10 mattpocock

Adding an additional data point where I just had the same issue inside a nestjs project where decorators are common. Had to comment out the decorators for the extension to identify the machine.

viglucci avatar Jul 27 '22 14:07 viglucci