-
Notifications
You must be signed in to change notification settings - Fork 67
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
feat(tsx): Prefix tsx output with a JSX pragma #917
Conversation
🦋 Changeset detectedLatest commit: 9a69bbf The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
!preview tsx-prefix |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine to me!
char := rune(buf[len(buf)-1:][0]) | ||
// If the existing buffer ends with any character other than ;, we need to add a `;` | ||
if char != ';' { | ||
p.addNilSourceMapping() | ||
p.print("\"\";") | ||
p.print("{};") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my tests, this seemed fine as a replacement of "";
, but I feel like there must be a reason I went for "";
back in the day. Can't remember it, though. I also wonder if TypeScript didn't fix a lot of those issues in the past 2 years...
(When I first joined Astro, it was ;//
, from withastro/language-tools#59 )
!preview tsx-prefix |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks good to me, but I wonder why ""
was replaced by {}
after frontmatter closing?
Ah, I forgot to mention the justification, it's because it's seen as a string pragma (like use client, use strict) and so TypeScript will attempt to move it at the top of the file, which messes with imports |
Ah ok, makes sense now |
Changes
Add
/** @jsxImportSource astro */
to our TSX output so it uses the newly exported types at withastro/astro#9501, this is all to attempt to fix withastro/language-tools#727Testing
Adjusted tests
Docs
N/A