statelyai / xstate-tools

Public monorepo for XState tooling
183 stars 40 forks source link

Typegen does not work with template literals in actions #213

Open lokhmakov opened 2 years ago

lokhmakov commented 2 years ago
Screenshot 2022-09-14 at 07 58 10
Andarist commented 2 years ago

To fix this we should add support for TemplateLiteral here: https://github.com/statelyai/xstate-tools/blob/e938f4c7eed2b92bf480a03c2ec8458d9bdd95f9/packages/machine-extractor/src/actions.ts#L85-L100

We already have some logic to handle TemplateLiterals (see the helper here) but it's not used for the actions. For example, it's used for transition targets here. However, extracting actions might be a little bit more complex as the return value might be slightly more complex than just the extracted string so it's probably not a matter of just adding a TemplateLiteral to the appropriate array.

As a quick fix one could just extend the referenced ActionAsString to handle TemplateLiterals too.

lokhmakov commented 2 years ago

Not really an issue for me, just trying to figure out why types don't work. Thanks.