Skip to content
This repository was archived by the owner on Aug 9, 2023. It is now read-only.

Commit cc8e974

Browse files
committed
Fix types to loosen h
1 parent fbb8309 commit cc8e974

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed

index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
* @callback CreateElementLike
1111
* @param {string} name
12-
* @param {Record<string, any>} [attributes]
12+
* @param {any} attributes
1313
* @param {Array.<string|any>} [children]
1414
* @returns {any}
1515
*
@@ -257,7 +257,7 @@ function addAttribute(props, prop, value, ctx, name) {
257257
*/
258258
function react(h) {
259259
/** @type {unknown} */
260-
const node = h('div')
260+
const node = h('div', {})
261261
return Boolean(
262262
node &&
263263
// @ts-expect-error Looks like a React node.
@@ -285,7 +285,7 @@ function hyperscript(h) {
285285
*/
286286
function vdom(h) {
287287
/** @type {unknown} */
288-
const node = h('div')
288+
const node = h('div', {})
289289
// @ts-expect-error Looks like a vnode.
290290
return node.type === 'VirtualNode'
291291
}
@@ -298,7 +298,7 @@ function vdom(h) {
298298
*/
299299
function vue(h) {
300300
/** @type {unknown} */
301-
const node = h('div')
301+
const node = h('div', {})
302302
// @ts-expect-error Looks like a Vue node.
303303
return Boolean(node && node.context && node.context._isVue)
304304
}

test.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ test('hast-to-hyperscript', (t) => {
198198
t.test('should support `virtual-dom/h`', (t) => {
199199
const baseline = doc.replace(/color:red;/, 'color: red;')
200200
/** @type {ReturnType<v>} */
201-
// @ts-expect-error Vue is too strict.
202201
const actual = toH(v, hast)
203202
const expected = v('div', {key: 'h-1'}, [
204203
v(
@@ -554,8 +553,6 @@ test('hast-to-hyperscript', (t) => {
554553
)
555554

556555
t.equal(
557-
// @ts-expect-error Types are wrong.
558-
// type-coverage:ignore-next-line
559556
toH(v, u('element', {tagName: 'div'}, [])).key,
560557
'h-1',
561558
'should patch `keys` on vdom'
@@ -574,7 +571,6 @@ test('hast-to-hyperscript', (t) => {
574571
t.deepEqual(
575572
vToString(
576573
toH(
577-
// @ts-expect-error Vue is too strict.
578574
v,
579575
u('element', {tagName: 'div', properties: {style: 'color:red'}}, [])
580576
)
@@ -676,24 +672,18 @@ test('hast-to-hyperscript', (t) => {
676672

677673
t.test('should support space', (t) => {
678674
t.equal(
679-
// @ts-expect-error Vue is too strict.
680-
// type-coverage:ignore-next-line
681675
toH(v, u('element', {tagName: 'div'}, [])).namespace,
682676
null,
683677
'should start in HTML'
684678
)
685679

686680
t.equal(
687-
// @ts-expect-error Vue is too strict.
688-
// type-coverage:ignore-next-line
689681
toH(v, u('element', {tagName: 'div'}, []), {space: 'svg'}).namespace,
690682
ns.svg,
691683
'should support `space: "svg"`'
692684
)
693685

694686
t.equal(
695-
// @ts-expect-error Vue is too strict.
696-
// type-coverage:ignore-next-line
697687
toH(v, u('element', {tagName: 'svg'}, [])).namespace,
698688
ns.svg,
699689
'should infer `space: "svg"`'

0 commit comments

Comments
 (0)