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

Breaks async template literal tags #372

Closed
frandiox opened this issue Sep 8, 2020 · 3 comments
Closed

Breaks async template literal tags #372

frandiox opened this issue Sep 8, 2020 · 3 comments

Comments

@frandiox
Copy link

frandiox commented Sep 8, 2020

Hi! First of all, thanks for this amazing tool!
There might be an issue with async template literals tags (such as https://github.com/porsager/postgres):

const result = await sql`select * from table`

is built as:

const result = (await sql)`select * from table`;

The parenthesis basically break the code and the whole thing just returns a Promise. instead of the actual result.

I've tried v0.6.30 and v0.6.32. I'm using the Rollup plugin https://github.com/egoist/rollup-plugin-esbuild with TS target es2018 -- same happens for es2016 but with yield instead of await.

Edit

This works:

const result = await (sql`select * from table`)

builds as:

const result = await sql`select * from table`;

However, formatters such as Prettier will likely remove those parenthesis before esbuild.

@evanw
Copy link
Owner

evanw commented Sep 8, 2020

Thanks for reporting this! It looks like the precedence of template literal tags is incorrect. I just fixed the bug and I will do a release later today.

@frandiox
Copy link
Author

frandiox commented Sep 9, 2020

@evanw Thank you so much!

@evanw
Copy link
Owner

evanw commented Sep 9, 2020

The fix was just released in version 0.6.33.

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