snabbdom / snabbdom

A virtual DOM library with focus on simplicity, modularity, powerful features and performance.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[bug] type checking of ElementChildrenAttribute failed with JsxVNodeChildren

TechQuery opened this issue · comments

Example

JSX declaration

import { VNode, JsxVNodeChildren } from 'snabbdom';

declare global {
    namespace JSX {
        type Element = VNode;

        interface ElementChildrenAttribute {
            defaultSlot: JsxVNodeChildren;
        }
    }
}

JSX code

<section>
    <h2>xxx</h2>

    {[1, 2, 3].map(value => <span>{value}</span>)}
    {/* Type 'VNode[]' is not assignable to type 'JsxVNodeChild'. ts(2322) */}
</section>

Context

https://github.com/EasyWebApp/WebCell/blob/c1e69152ab4fa5d219469deaf310ef5a483d8861/source/utility/vDOM.ts#L59-L61

Environment

  • SnabbDOM: 3.5.0
  • TypeScript: 4.7.3

You should not need any JSX declaration, snabbdom already provides these

But WebCell has more property types for DOM & Component node, and SnabbDOM's h() & Fragment() are not fulfilled all my situations, so I need some wrappers.