Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: type definition of h() function does not match implementation. #6181

Open
3 tasks done
trusktr opened this issue Mar 2, 2025 · 1 comment
Open
3 tasks done
Labels
Bug: Validated This PR or Issue is verified to be a bug within Stencil Help Wanted

Comments

@trusktr
Copy link

trusktr commented Mar 2, 2025

Prerequisites

Stencil Version

4.26.0

Current Behavior

The type definition of the h() function does match the runtime definition.

Expected Behavior

Expect the types to match.

System Info

n/a

Steps to Reproduce

Look at the implementation:

export const h = (nodeName: any, vnodeData: any, ...children: d.ChildType[]): d.VNode => {

Look at the type definition users see:

export declare function h(sel: any): VNode;
export declare function h(sel: Node, data: VNodeData | null): VNode;
export declare function h(sel: any, data: VNodeData | null): VNode;
export declare function h(sel: any, text: string): VNode;
export declare function h(sel: any, children: Array<VNode | undefined | null>): VNode;
export declare function h(sel: any, data: VNodeData | null, text: string): VNode;
export declare function h(sel: any, data: VNodeData | null, children: Array<VNode | undefined | null>): VNode;
export declare function h(sel: any, data: VNodeData | null, children: VNode): VNode;

Code Reproduction URL

Example:

import {h} from '@stencil/core';

const test1 = h('div', { id: 'foo' },
  'bar',





  h('img', { src: 'foo.png' }),
  h('span', { id: 'bar' },
    h('img', { src: 'bar.png' })),
);

Result:

Image

Additional Information

Looks like the type definition exported publicly is hand-written, and not derived from the actual types of the implementation.

For example, the implementation accepts ...children but the public type definition does not.

@christian-bromann christian-bromann added Bug: Validated This PR or Issue is verified to be a bug within Stencil Help Wanted labels Mar 2, 2025
@christian-bromann
Copy link
Member

Thanks for raising this issue. I do not have enough historical context to know why we have different definitions for this. I am open to suggestions. Any contributions are much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug: Validated This PR or Issue is verified to be a bug within Stencil Help Wanted
Projects
None yet
Development

No branches or pull requests

2 participants