Skip to content

Commit 79ad7d1

Browse files
committed
Fix type-coverage issues
1 parent c4ed721 commit 79ad7d1

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

lib/index.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,9 @@ function productionCreate(_, jsx, jsxs) {
759759
/** @type {Create<JsxFunction>} */
760760
function create(_, type, props, key) {
761761
// Only an array when there are 2 or more children.
762-
const isStaticChildren = Array.isArray(props.children)
762+
const isStaticChildren = Array.isArray(
763+
/** @type {Record<String, unknown>} */ (props).children
764+
)
763765
const fn = isStaticChildren ? jsxs : jsx
764766
return key ? fn(type, props, key) : fn(type, props)
765767
}
@@ -780,7 +782,9 @@ function developmentCreate(filePath, jsxDEV) {
780782
/** @type {Create<JsxFunction>} */
781783
function create(node, type, props, key) {
782784
// Only an array when there are 2 or more children.
783-
const isStaticChildren = Array.isArray(props.children)
785+
const isStaticChildren = Array.isArray(
786+
/** @type {Record<String, unknown>} */ (props).children
787+
)
784788
const point = pointStart(node)
785789
return jsxDEV(
786790
type,

test/index.js

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/**
22
* @typedef {import('estree').Program} Program
3+
* @typedef {import('hast').Nodes} Nodes
34
*
45
* @typedef {import('hast-util-to-jsx-runtime').CreateEvaluater<typeof production.jsx>} CreateEvaluater
56
*
@@ -549,6 +550,9 @@ test('components', async function (t) {
549550
...production,
550551
passNode: true,
551552
components: {
553+
/**
554+
* @param {{ node: Nodes }} props
555+
*/
552556
b(props) {
553557
assert.ok(props.node)
554558
return 'a'
@@ -567,6 +571,9 @@ test('components', async function (t) {
567571
toJsxRuntime(h('b'), {
568572
...production,
569573
components: {
574+
/**
575+
* @param {{ node: Nodes }} props
576+
*/
570577
b(props) {
571578
assert.equal(props.node, undefined)
572579
return 'a'

0 commit comments

Comments
 (0)