Skip to content

fix(astro): Protect component prop types#3846

Merged
wobsoriano merged 3 commits intomainfrom
astro-protect-props-fix
Jul 31, 2024
Merged

fix(astro): Protect component prop types#3846
wobsoriano merged 3 commits intomainfrom
astro-protect-props-fix

Conversation

@wobsoriano
Copy link
Member

@wobsoriano wobsoriano commented Jul 30, 2024

Description

This PR addresses an issue where the <Protect /> component was accepting any prop without TypeScript raising errors. All the Astro components does not have a build step, and directly copied to components/*, so relative paths will not be resolvable.

Screenshot 2024-07-30 at 3 29 41 PM Screenshot 2024-07-30 at 4 34 14 PM

Checklist

  • npm test runs as expected.
  • npm run build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

@changeset-bot
Copy link

changeset-bot bot commented Jul 30, 2024

🦋 Changeset detected

Latest commit: 6c66ae7

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

This PR includes changesets to release 1 package
Name Type
@clerk/astro 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

Comment on lines +77 to +98
(
| {
condition?: never;
role: OrganizationCustomRoleKey;
permission?: never;
}
| {
condition?: never;
role?: never;
permission: OrganizationCustomPermissionKey;
}
| {
condition: (has: CheckAuthorizationWithCustomPermissions) => boolean;
role?: never;
permission?: never;
}
| {
condition?: never;
role?: never;
permission?: never;
}
) & {
Copy link
Member Author

Choose a reason for hiding this comment

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

We need to separate the prop types of the Astro component and React component since the Astro one has no build step and imported types will not be resolvable.

Copy link
Member

Choose a reason for hiding this comment

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

Would the astro prop types need fallback: never; added?

Copy link
Member Author

Choose a reason for hiding this comment

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

If the purpose of adding fallback: never is to show an error whenever unexpected props are used in Astro <Protect />, we don't need it it since it should already show type errors for random props

Also just FYI, Astro does not support typed slots

@wobsoriano wobsoriano marked this pull request as ready for review July 30, 2024 23:29
@wobsoriano wobsoriano merged commit ac20057 into main Jul 31, 2024
@wobsoriano wobsoriano deleted the astro-protect-props-fix branch July 31, 2024 14:37
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.

3 participants