statelyai / xstate-tools

Public monorepo for XState tooling
183 stars 36 forks source link

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

Open tastyqbit opened 1 year ago

tastyqbit commented 1 year ago

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
davidkpiano commented 1 year ago

@Andarist Is this feasible?

Andarist commented 1 year ago

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.