fix(declarations): add rest params to h()#6604
Merged
johnjenkins merged 2 commits intostenciljs:mainfrom Feb 19, 2026
Merged
Conversation
The public type definition of h() does not include a rest parameter
overload for children, even though the runtime implementation accepts
`...children: ChildType[]`. This causes type errors when passing
multiple children as separate arguments, e.g.:
h('div', null, 'text', h('span', null), h('img', null))
Add an overload accepting `...children: (VNode | string | number)[]`
to both the `h` namespace and the standalone declarations, matching
the runtime behavior.
Also move a misplaced `h(sel, data, children: VNode)` overload that
was separated from the other overloads by the jsx declarations.
fixes: stenciljs#6181
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a type definition mismatch where the public type declarations for the h() function did not include a rest parameter overload for children, even though the runtime implementation has always supported ...children as rest parameters. This caused TypeScript errors when passing multiple children as separate arguments. Additionally, one h() overload was misplaced after the JSX runtime function declarations and has been moved back with the other h() overloads.
Changes:
- Added
...children: (VNode | string | number)[]rest parameter overload to both thehnamespace and standalone function declarations - Moved the misplaced
h(sel: any, data: VNodeData | null, children: VNode)overload from after thejsxDEVdeclaration back to the correct location with otherh()overloads
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
johnjenkins
approved these changes
Feb 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the current behavior?
The public type definition of
h()does not include a rest parameter overload for children, even though the runtime implementation accepts...children: ChildType[]. This causes type errors when passing multiple children as separate arguments:Additionally, one
h()overload (sel, data, children: VNode) was misplaced after the jsx function declarations, separated from the otherh()overloads.GitHub Issue Number: #6181
What is the new behavior?
Add a
...children: (VNode | string | number)[]rest parameter overload to both thehnamespace and standalone declarations, matching the runtime implementation. The above example now type-checks correctly.The misplaced overload is moved back with the other
h()overloads.Documentation
N/A
Does this introduce a breaking change?
This only adds new overloads — existing code that type-checks today will continue to work.
Testing
This change only affects type declarations. The runtime
h()function and its tests (src/runtime/vdom/test/h.spec.ts) are unchanged. The existing tests already exercise rest parameter usage (e.g.h('div', null, 'child 1', 'child 2')), confirming the runtime has always supported this pattern.Other information
The type definitions in
stencil-public-runtime.tsare hand-written and were not derived from the runtime implementation, which is why they drifted apart.