Skip to content

fix: jsx types#6702

Merged
johnjenkins merged 2 commits into
v5from
v5-fix-jsx-types
May 5, 2026
Merged

fix: jsx types#6702
johnjenkins merged 2 commits into
v5from
v5-fix-jsx-types

Conversation

@johnjenkins
Copy link
Copy Markdown
Contributor

@johnjenkins johnjenkins commented May 5, 2026

What is the current behavior?

GitHub Issue Number: N/A

What is the new behavior?

Fixes: #5306
Closes: #5307

TypeScript now correctly resolves Stencil's JSX element type.
Previously, JSX.Element was undefined in the h namespace, causing TypeScript to silently fall back to any for JSX expressions — surfaced as no-unsafe-return errors in strict @typescript-eslint setups.

Three type-level changes:

h.JSX.Element is now VNode
Host and Fragment are typed as (props) => VNode instead of FunctionalComponent<...>
FunctionalComponent<T> return type narrowed from VNode | VNode[] | null to VNode | null

Migration

No runtime changes — types only.

If you have a FunctionalComponent<T> that returns an array (via utils.map or similar), wrap the result in a fragment instead:

// Before
const MyList: FunctionalComponent<Props> = (props, children, utils) =>
  utils.map(children, transform);
// After
const MyList: FunctionalComponent<Props> = (props, children, utils) => (
  <>{utils.map(children, transform)}</>
);

Documentation

Does this introduce a breaking change?

  • Yes
  • No

Testing

Other information

@johnjenkins johnjenkins requested a review from a team as a code owner May 5, 2026 21:51
@johnjenkins johnjenkins merged commit 591aa27 into v5 May 5, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant