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

Bug: Typegen cannot detect actions defined by variable imported from outside the file

Open tastyqbit opened this issue 3 years ago • 2 comments

Description

I am trying to set the key of each state to be 1 of a list of urls defined outside the createMachine file.

Screenshot 2022-11-08 at 13 56 53

If I define the RouteUrls object locally inside the file, then the error disappears making me think that typegen does not work well with other files. Is there anything I can do?

Expected result

The typegen should detect that the action is tied to an imported value just like if I add a string directly

Screenshot 2022-11-08 at 14 01 06

Actual result

The typing system does not recongise the link between the definition of the state and the usage of an action/service that are linked by an imported variable from a different file

Screenshot 2022-11-08 at 13 56 53

tastyqbit avatar Nov 08 '22 12:11 tastyqbit

@Andarist Is this feasible?

davidkpiano avatar Jan 23 '23 04:01 davidkpiano

Not at the moment. As discussed in Lisbon - this is tricky, especially with all of the resolution modes/aliases that one can have. We can explore this in the future but for the time-being, we need to focus on the basic "one file" experience.

Andarist avatar Jan 23 '23 12:01 Andarist