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

Expected ";" but found "const" - typescript transformer #997

Open
bartlomiejzuber opened this issue Apr 3, 2024 · 3 comments
Open

Expected ";" but found "const" - typescript transformer #997

bartlomiejzuber opened this issue Apr 3, 2024 · 3 comments
Labels
- P4: important Violate documented behavior or significantly improves performance (priority)

Comments

@bartlomiejzuber
Copy link

bartlomiejzuber commented Apr 3, 2024

What version of @astrojs/compiler are you using?

2.8.1

What package manager are you using?

npm

What operating system are you using?

Linux

Describe the Bug

In this code sample, the export statement is hoisted, but as const is not.

---
export const allAboutUsPreviewCards = [
] as const;
---

as const is correctly hoisted if the const declaration is only takes up one line.

Link to Minimal Reproducible Example

Live Astro Compiler

@github-actions github-actions bot added the needs triage Issue needs to be triaged label Apr 3, 2024
@ematipico ematipico added ecosystem: upstream Issue is caused by a bug / missing feature upstream and removed needs triage Issue needs to be triaged labels Apr 3, 2024
@ematipico
Copy link
Member

This is an issue with esbuild. I suggest filing an issue there: link to their playground

@ematipico ematipico closed this as not planned Won't fix, can't repro, duplicate, stale Apr 3, 2024
@lilnasy lilnasy reopened this Apr 3, 2024
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Apr 3, 2024
@lilnasy
Copy link
Contributor

lilnasy commented Apr 3, 2024

After looking at the response in the esbuild issue, it's clear this is an issue with the compiler.

Export statements are hoisted, which is a term we use for moving code such that it runs at the top-level instead of component-level. It seems like the the variable declaration itself is hoisted, but as const is not, creating invalid typescript code.

@lilnasy lilnasy transferred this issue from withastro/astro Apr 3, 2024
@ematipico ematipico added - P3: minor bug An edge case that only affects very specific usage (priority) and removed ecosystem: upstream Issue is caused by a bug / missing feature upstream needs triage Issue needs to be triaged labels Apr 3, 2024
@lilnasy
Copy link
Contributor

lilnasy commented Apr 3, 2024

Updated the issue description to focus on incorrect compilation.

@lilnasy lilnasy added - P4: important Violate documented behavior or significantly improves performance (priority) and removed - P3: minor bug An edge case that only affects very specific usage (priority) labels Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P4: important Violate documented behavior or significantly improves performance (priority)
Projects
None yet
Development

No branches or pull requests

3 participants