From c879e26ed6302ab6c6cd7954f2f202d8b8db8035 Mon Sep 17 00:00:00 2001 From: JounQin Date: Thu, 19 Mar 2026 16:27:00 +0800 Subject: [PATCH] fix(types): should accept Child and Properties at the same time --- lib/create-h.js | 2 +- test-d/index.ts | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/create-h.js b/lib/create-h.js index 4e90f33..7f4b183 100644 --- a/lib/create-h.js +++ b/lib/create-h.js @@ -86,7 +86,7 @@ export function createH(schema, defaultTagName, caseSensitive) { * * @overload * @param {string} selector - * @param {Properties} properties + * @param {Child | Properties} properties * @param {...Child} children * @returns {Element} * diff --git a/test-d/index.ts b/test-d/index.ts index d43bb0b..a3e20b5 100644 --- a/test-d/index.ts +++ b/test-d/index.ts @@ -45,6 +45,14 @@ expectType(h('', {p: {x: 1}})) // Style // @ts-expect-error: not a property value. h('', {p: {x: true}}) +declare const propsOrChild: + | Record + | string + | null + | undefined + +expectType(h('', propsOrChild)) + expectType( s('svg', {viewbox: '0 0 500 500', xmlns: 'http://www.w3.org/2000/svg'}, [ s('title', 'SVG `