refactor(mdxish): extend table types to reflect flow-content cells#1446
Open
eaglethrost wants to merge 8 commits into
Open
refactor(mdxish): extend table types to reflect flow-content cells#1446eaglethrost wants to merge 8 commits into
eaglethrost wants to merge 8 commits into
Conversation
eaglethrost
commented
Apr 24, 2026
| * Extension of MDAST's Root that has some custom extended content types | ||
| * E.g. Tables whose cells carry flow content beyond mdast’s built-in `TableCell` typing. | ||
| */ | ||
| export interface MdxishMdastRoot extends Omit<Root, 'children'> { |
Contributor
Author
There was a problem hiding this comment.
I've put the Root extension interface here in case we want to use it in a consumer. Since this is a superset of Root, we don't need to use it, but of course it would be better typing for the Table serialisation / deserialisation code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎯 What does this PR do?
Follow-up on #1445 to improve the typing around tables. The issue was mdast's built-in
TableCellis typed asPhrasingContent[], but our pipeline processes and put block-level nodes (paragraphs, lists, code) inside cells so they can serialize to JSX<Table>with proper paragraph separation. The mismatch meant the tests and transformers leaned onas Table/as TableCellcasts to force the data through. Nothing was wrong at runtime, but good to clean up so the types describe what actually flows through and call sites don't need unsafe casts.Solution is to add a small set of mdxish-specific table types (
MdxishTable,MdxishTableRow,MdxishTableCell,MdxishMdastRoot) that widenTableCell.childrento the content the serializer actually accepts. The transformers now return/consume these shapes, and the test fixtures useMdxishMdastRootinstead of casting each table literal.processor/transform/mdxish/types.ts+MdxishMdastRootre-exported fromtypes.d.tsmdxish-jsx-to-mdast.tsandtables/mdxish-tables-to-jsx.tsuse the wider shapes; no moreas TableCell/as Tableat cell pushes__tests__/lib/mdxish/mdxishMdastToMd.test.tstyped asMdxishMdastRoot— all 14as Tablecasts gone🧪 QA tips