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

🐛 BUG: [TSX] Multiline comments are handled weirdly #784

Closed
Princesseuh opened this issue May 2, 2023 · 2 comments · Fixed by #930
Closed

🐛 BUG: [TSX] Multiline comments are handled weirdly #784

Princesseuh opened this issue May 2, 2023 · 2 comments · Fixed by #930
Assignees
Labels
- P2: has workaround Bug, but has workaround (priority) feat: tsx Related to the TSX output (scope)

Comments

@Princesseuh
Copy link
Member

What version of @astrojs/compiler are you using?

1.3.2

What package manager are you using?

pnpm

What operating system are you using?

macOS

Describe the Bug

Multilines comments seems to not be handled properly, they move around, disappear.. real magicians over there.

For instance, the following code:

{/* @ts-expect-error */}
<Component prop="value"></Component>

{
// @ts-expect-error
}
<Component prop="value"></Component>

{
/* @ts-expect-error */
<Component prop="value"></Component>
}

{
// @ts-expect-error
<Component prop="value"></Component>
}

Becomes this TSX:

<Fragment>

<Component prop="value"></Component>

{
// @ts-expect-error
}
<Component prop="value"></Component>

{
/* @ts-expect-error */<Fragment><Component prop="value"></Component></Fragment>}

{
// @ts-expect-error
<Fragment><Component prop="value"></Component></Fragment>}
</Fragment>

For the average comment, this doesn't really matter. However, it matters for TS pragmas, as their position is important.

Link to Minimal Reproducible Example

See description

@Princesseuh Princesseuh changed the title 🐛 BUG: TSX Multiline comments are handled weirdly 🐛 BUG: [TSX] Multiline comments are handled weirdly May 2, 2023
@natemoo-re natemoo-re added the feat: tsx Related to the TSX output (scope) label Jun 27, 2023
@Princesseuh Princesseuh added the - P2: has workaround Bug, but has workaround (priority) label Nov 12, 2023
@MoustaphaDev
Copy link
Member

Would you expect this to be the correct output?

<Fragment>

<Component prop="value"></Component>

<Component prop="value"></Component>

{
/* @ts-expect-error */
<Fragment><Component prop="value"></Component></Fragment>
}

{
// @ts-expect-error
<Fragment><Component prop="value"></Component></Fragment>
}
</Fragment>

@Princesseuh
Copy link
Member Author

I would expect all forms to maintain their shape, so the following would be the optimal result:

<Fragment>

{/* @ts-expect-error */}
<Component prop="value"></Component>

{
// @ts-expect-error
}
<Component prop="value"></Component>

{
/* @ts-expect-error */
<Fragment><Component prop="value"></Component></Fragment>
}

{
// @ts-expect-error
<Fragment><Component prop="value"></Component></Fragment>
}
</Fragment>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P2: has workaround Bug, but has workaround (priority) feat: tsx Related to the TSX output (scope)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants