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

Fix expected types for Element in our JSX definitions #3958

Merged
merged 2 commits into from
Jul 18, 2022

Conversation

Princesseuh
Copy link
Member

Changes

In a recent PR we fixed an import to AstroComponentFactory, this had the side effect of making our expected type for Element too strict (due to TypeScript weirdness), which lead to users encountering errors when using JSX frameworks

Also, this PR fixes the JSX definitions not working properly in the monorepo (finally!)

Fix #3945

Testing

Tested manually, also ran the language-server test suite with this changes and everything passed

Docs

N/A

@changeset-bot
Copy link

changeset-bot bot commented Jul 18, 2022

🦋 Changeset detected

Latest commit: 4d13cf0

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

This PR includes changesets to release 9 packages
Name Type
astro Patch
@e2e/astro-component Patch
@e2e/lit-component Patch
@e2e/preact-component Patch
@e2e/react-component Patch
@e2e/solid-component Patch
@e2e/svelte-component Patch
@e2e/e2e-tailwindcss Patch
@e2e/ts-resolution 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

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Jul 18, 2022
// This is an unfortunate use of `any`, but unfortunately we can't make a type that works for every framework
// without importing every single framework's types (which comes with its own set of problems).
// Using any isn't that bad here however as in Astro files the return type of a component isn't relevant in most cases
type Element = HTMLElement | any;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not really a change, previously since the AstroComponentFactory import didn't work, this always counted as HTMLElement | any. So this just brings back the previous (pre beta 72) behaviour

@Princesseuh Princesseuh merged commit 8eba6d9 into main Jul 18, 2022
@Princesseuh Princesseuh deleted the fix-jsx-element-type branch July 18, 2022 15:45
@astrobot-houston astrobot-houston mentioned this pull request Jul 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
2 participants