🐛 BUG: Comments parsing inside JSX #956
Labels
- P3: minor bug
An edge case that only affects very specific usage (priority)
feat: tsx
Related to the TSX output (scope)
Describe the Bug
First of all, I am not sure if this issue belong to the
language-tools
, thecompiler
or theastro
repository. So sorry if I picked the wrong repo.System info
I have the same issue using Node
v21.5.0
.The issue
I can write comments inside JSX like this:
However, if I want to use a comment between the props, it does not work:
On the same line, it does not work neither:
With these examples, I got
Unterminated string literal. ts(1002)
.If I try to put a comment in a ternary like this:
Then I see:
The same error happens if I use the following format:
/* This is a comment */
.In another project using ESlint, it is not Typescript who is complaining but ESlint:
And Prettier does not work neither, it complains with
SyntaxError: Unexpected token
.My expectations
I expect to be able to use comments this way since this pattern is commonly used to disable a linter like ESlint:
Steps to Reproduce
I created a project in Stackblitz ( https://stackblitz.com/edit/astro-comments-parsing-bug?file=src%2Fpages%2Findex.astro ) but the parser does not work (I have a warning in the console
No parser for file type: astro
) so you can download it and open the project in VS Code or you can follow the instructions below.npm create astro@latest -- --template basics
Yes
for all (and keepStrict
for Typescript)./src/pages/index.astro
with:The text was updated successfully, but these errors were encountered: