Skip to content

Commit

Permalink
Update @types/hast, unified, utilities, etc
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Aug 31, 2023
1 parent 9781c2d commit 73c4fb0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
7 changes: 5 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ export default function rehypeReact(options) {

Object.assign(this, {Compiler: compiler})

/** @type {import('unified').CompilerFunction<Root, ReactNode>} */
// @ts-expect-error: to do: register result.
/** @type {import('unified').Compiler<Root, ReactNode>} */
function compiler(node) {
/** @type {ReactNode} */
let result = toH(
Expand Down Expand Up @@ -108,7 +109,9 @@ export default function rehypeReact(options) {
// See: <https://github.com/rehypejs/rehype-react/pull/32>.
// See: <https://github.com/rehypejs/rehype-react/pull/45>.
if (children && tableElements.has(name)) {
children = children.filter((child) => !whitespace(child))
children = children.filter(
(child) => typeof child !== 'string' || !whitespace(child)
)
}

if (options.components && own.call(options.components, name)) {
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@
],
"dependencies": {
"@mapbox/hast-util-table-cell-style": "^0.2.0",
"@types/hast": "^2.0.0",
"@types/hast": "^3.0.0",
"hast-to-hyperscript": "^10.0.0",
"hast-util-whitespace": "^2.0.0",
"unified": "^10.0.0"
"hast-util-whitespace": "^3.0.0",
"unified": "^11.0.0"
},
"peerDependencies": {
"@types/react": ">=17"
Expand All @@ -58,7 +58,7 @@
"@types/react-dom": "^18.0.0",
"@types/tape": "^5.0.0",
"c8": "^8.0.0",
"hastscript": "^7.0.0",
"hastscript": "^8.0.0",
"prettier": "^3.0.0",
"react": "^18.0.0",
"react-dom": "^18.0.0",
Expand All @@ -69,7 +69,7 @@
"tape": "^5.0.0",
"type-coverage": "^2.0.0",
"typescript": "^5.0.0",
"unist-builder": "^3.0.0",
"unist-builder": "^4.0.0",
"xo": "^0.56.0"
},
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ test('React ' + React.version, (t) => {
)

t.deepEqual(
// @ts-expect-error: plugin is typed as only supporting roots.
// To do: this should error, because it’s not a root.
processor.stringify(h('p')),
React.createElement('p', {key: 'h-1'}, undefined),
'should transform an element'
Expand Down Expand Up @@ -132,6 +132,7 @@ test('React ' + React.version, (t) => {

t.deepEqual(
server.renderToStaticMarkup(
// @ts-expect-error: to do: figure out.
unified()
.use(rehypeReact, {
createElement: React.createElement,
Expand Down

0 comments on commit 73c4fb0

Please sign in to comment.