Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typegen does not work with template literals in actions #213

Open
lokhmakov opened this issue Sep 14, 2022 · 2 comments · May be fixed by #222
Open

Typegen does not work with template literals in actions #213

lokhmakov opened this issue Sep 14, 2022 · 2 comments · May be fixed by #222

Comments

@lokhmakov
Copy link

Screenshot 2022-09-14 at 07 58 10

@Andarist
Copy link
Member

To fix this we should add support for TemplateLiteral here:

export const ActionAsString = maybeTsAsExpression(
maybeIdentifierTo(
createParser({
babelMatcher: t.isStringLiteral,
parseNode: (node, context): ActionNode => {
return {
action: node.value,
node,
name: node.value,
declarationType: "named",
inlineDeclarationId: context.getNodeHash(node),
};
},
}),
),
);

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
Copy link
Author

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

@with-heart with-heart linked a pull request Sep 22, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants