Skip to content

feat(tsx): Prefix tsx output with a JSX pragma#917

Merged
Princesseuh merged 4 commits intomainfrom
fix/tsx-prefix
Jan 2, 2024
Merged

feat(tsx): Prefix tsx output with a JSX pragma#917
Princesseuh merged 4 commits intomainfrom
fix/tsx-prefix

Conversation

@Princesseuh
Copy link
Copy Markdown
Member

@Princesseuh Princesseuh commented Dec 20, 2023

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#727

Testing

Adjusted tests

Docs

N/A

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Dec 20, 2023

🦋 Changeset detected

Latest commit: 9a69bbf

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@astrojs/compiler Patch

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

@Princesseuh
Copy link
Copy Markdown
Member Author

!preview tsx-prefix

@github-actions
Copy link
Copy Markdown
Contributor

 > root@0.0.0 release /home/runner/work/compiler/compiler > changeset publish "--tag" "next--tsx-prefix" 🦋 warn ===============================IMPORTANT!=============================== 🦋 warn Packages will be released under the next--tsx-prefix tag 🦋 warn ---------------------------------------------------------------------- 🦋 info npm info @astrojs/compiler 🦋 info @astrojs/compiler is being published because our local version (0.0.0-tsx-prefix-20231221053005) has not been published on npm 🦋 info Publishing "@astrojs/compiler" at "0.0.0-tsx-prefix-20231221053005" 🦋 success packages published successfully: 🦋 @astrojs/compiler@0.0.0-tsx-prefix-20231221053005 🦋 Creating git tag... 🦋 New tag: @astrojs/compiler@0.0.0-tsx-prefix-20231221053005

Copy link
Copy Markdown
Member

@natemoo-re natemoo-re left a 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!

@Princesseuh Princesseuh marked this pull request as ready for review December 29, 2023 05:34
if char != ';' {
p.addNilSourceMapping()
p.print("\"\";")
p.print("{};")
Copy link
Copy Markdown
Member Author

@Princesseuh Princesseuh Dec 29, 2023

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 )

@Princesseuh
Copy link
Copy Markdown
Member Author

!preview tsx-prefix

@github-actions
Copy link
Copy Markdown
Contributor

 > root@0.0.0 release /home/runner/work/compiler/compiler > changeset publish "--tag" "next--tsx-prefix" 🦋 warn ===============================IMPORTANT!=============================== 🦋 warn Packages will be released under the next--tsx-prefix tag 🦋 warn ---------------------------------------------------------------------- 🦋 info npm info @astrojs/compiler 🦋 info @astrojs/compiler is being published because our local version (0.0.0-tsx-prefix-20231229054418) has not been published on npm 🦋 info Publishing "@astrojs/compiler" at "0.0.0-tsx-prefix-20231229054418" 🦋 success packages published successfully: 🦋 @astrojs/compiler@0.0.0-tsx-prefix-20231229054418 🦋 Creating git tag... 🦋 New tag: @astrojs/compiler@0.0.0-tsx-prefix-20231229054418

Copy link
Copy Markdown
Member

@MoustaphaDev MoustaphaDev left a 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?

@Princesseuh
Copy link
Copy Markdown
Member Author

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

@MoustaphaDev
Copy link
Copy Markdown
Member

Ah ok, makes sense now

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 this pull request may close these issues.

🐛 BUG: astro check reports incorrect errors on HTMLAttributes

3 participants