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

Individual TemplateElements are not supported #129

Closed
magiblot opened this issue Oct 8, 2019 · 3 comments
Closed

Individual TemplateElements are not supported #129

magiblot opened this issue Oct 8, 2019 · 3 comments
Labels

Comments

@magiblot
Copy link
Contributor

magiblot commented Oct 8, 2019

Hello,

The structure of TemplateLiteral is as follows:

imatge

The elements of quasis are TemplateElement nodes. When parsing TemplateLiteral nodes, astring accesses the quasis' content directly:

state.write(quasis[i].value.raw)

This is OK unless you ask astring to parse the TemplateElement node individually. In that case, astring will crash as it doesn't have a specific method for this node type.

I wonder if this was an oversight or if it is intentional. Should I just write my own generator for TemplateElement?

Thank you very much.

@davidbonnet
Copy link
Owner

Thanks for reporting this. You're right, Astring should render any Estree node. Failing to do so should be considered a bug. Feel free to submit a PR.

@davidbonnet davidbonnet added the bug label Oct 8, 2019
@magiblot
Copy link
Contributor Author

magiblot commented Oct 8, 2019

It doesn't seem too hard, though I don't know what to do with the EXPRESSIONS_PRECEDENCE values. What should the value for TemplateElement be?

@davidbonnet
Copy link
Owner

No EXPRESSIONS_PRECEDENCE required. All there is to do is to add an extra handler called TemplateElement that does state.write(quasis[i].value.raw).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants