Skip to content

feat: More generic type guards #1919

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

Merged
merged 5 commits into from
Aug 8, 2025
Merged

Conversation

matthewlipski
Copy link
Collaborator

No description provided.

Copy link

vercel bot commented Aug 5, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
blocknote ❌ Failed (Inspect) Aug 6, 2025 3:22pm
blocknote-website ❌ Failed (Inspect) Aug 6, 2025 3:22pm

if (
editorHasBlockWithTypeAndProps(editor, "heading", {
level: defaultBlockSpecs["heading"].config.propSchema.level,
isToggleable: {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's think ahead here & try to figure out how this would work for both the current schema system & a zod-based one. I'm not sure that we should have to pass a propschema into this function.

I guess there are two types of checks we may want:

  • checking that a prop exists in the schema (i.e. does this editor even support toggle blocks)
  • checking that a prop matches a shape we expect for this function (i.e. is isToggleable a boolean)

How might we express that with zod?

I think in zod, whether a prop exists is easy, is there a zod validator for this key. (I also have the feeling this is the more common check).

Then to actually check if it fits what we expect, we would have to run the validator?

So maybe these checks should be de-coupled, i.e. separate checks?

@nperez0111 nperez0111 merged commit 760be84 into default-blocks Aug 8, 2025
0 of 6 checks passed
@nperez0111 nperez0111 deleted the default-blocks-type-guards branch August 8, 2025 11:45
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.

2 participants