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!: Reorganize SDK types to tighten helpers around custom props #18

Merged
merged 6 commits into from
Dec 18, 2023

Conversation

blaine-arcjet
Copy link
Contributor

Closes #17

This reworks how some types are represented within arcjet and @arcjet/next to avoid passing rule types deep into the type tree. Instead, we'll now extract the ExtraProps at the SDK type so it no longer looks like Arcjet<Primitive<{}> | Product<{ email: string }>> but instead Arcjet<{ email: string }>. This allows us to tighten the props on withArcjet and createMiddleware because they use the WithoutCustomProps utility.

This is a breaking change to @arcjet/next because I made createMiddleware take the instantiated SDK instead of configuration, which made it easier to adjust these types.

I also took the opportunity to remove some type utility exports because I wanted to rename the EmptyObject for a nicer type error message.

With these changes, this now provides a type error when you try to use protectSignup with the middleware:
Screenshot 2023-12-11 at 4 49 18 PM

Copy link
Contributor

@davidmytton davidmytton left a comment

Choose a reason for hiding this comment

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

Can you also open a PR for the docs changes for the new middleware signature please? Then I can test.

@blaine-arcjet
Copy link
Contributor Author

@davidmytton I've updated the example in this repo. Happy to update the example app and docs once this change is published since doing it before would cause compilation errors.

@blaine-arcjet blaine-arcjet merged commit 3b0c1fb into main Dec 18, 2023
8 checks passed
@blaine-arcjet blaine-arcjet deleted the phated/tighten-next-helpers branch December 18, 2023 21:09
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.

Tighten type checking on createMiddleware and withArcjet
2 participants