Skip to content

Make Schema.children strongly typed - #633

Merged
maxblank-stripe merged 1 commit into
mainfrom
yue/schema-children-type
Jul 20, 2026
Merged

maxblank-stripe merged 1 commit into
mainfrom
yue/schema-children-type

Conversation

@yue-stripe

@yue-stripe yue-stripe commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • type Schema.children as NodeType[]
  • bump the package version from 0.5.8 to 0.5.9

Why

Schema.children gets used during invalid child validation in src/validator.ts:

markdoc/src/validator.ts

Lines 278 to 285 in d351d70

for (const { type } of node.children) {
if (schema.children && type !== 'error' && !schema.children.includes(type))
errors.push({
id: 'child-invalid',
level: 'warning',
message: `Can't nest '${type}' in '${node.tag || node.type}'`,
});
}

That logic checks each parsed child node type against schema.children at runtime. If a schema supplies an unsupported child value, it is silently ignored because it never matches any parsed node type. Strongly typing children turns that mistake into a type error instead of letting it slip through and misleading users into thinking providing a tag name will enable validation.

Testing

  • npm run type:check passes

Committed-By-Agent: codex
Co-authored-by: codex <[email protected]>

@maxblank-stripe maxblank-stripe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm

@maxblank-stripe
maxblank-stripe merged commit afee1a4 into main Jul 20, 2026
5 checks passed
@maxblank-stripe
maxblank-stripe deleted the yue/schema-children-type branch July 20, 2026 18:48
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