Skip to content

fix(react): support React 17 JSX typing#1465

Merged
Anber merged 2 commits intocallstack:masterfrom
Anber:fix/react17-jsx-typing
Jan 26, 2026
Merged

fix(react): support React 17 JSX typing#1465
Anber merged 2 commits intocallstack:masterfrom
Anber:fix/react17-jsx-typing

Conversation

@Anber
Copy link
Collaborator

@Anber Anber commented Jan 26, 2026

Motivation

React 17 projects are currently hitting TS errors like:

  • Property 'children' is missing ... (TS2741)

This is related to how @linaria/react wires up JSX.IntrinsicElements for styled.*.

This PR is a follow-up/superset of the discussion in #1450, but avoids relying on @ts-expect-error and adds a small regression test.

Summary

  • Avoid exporting an empty react.JSX.IntrinsicElements via module augmentation.
  • Resolve intrinsic element props from React.JSX.IntrinsicElements only when React actually provides it; otherwise fall back to global JSX.IntrinsicElements.
  • Add a minimal dtslint suite (packages/react/__dtslint-react17__) that simulates React 17 + jsx: react-jsx and asserts styled.button does not require children.
  • Narrow packages/react/tsconfig.json to include: ["src"] so build/typecheck don’t accidentally pull in __dtslint* folders.

Test plan

  • pnpm turbo run typecheck test:dts --filter @linaria/react
  • pnpm lint

@changeset-bot
Copy link

changeset-bot bot commented Jan 26, 2026

🦋 Changeset detected

Latest commit: fb2444e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
@linaria/react Patch
@linaria/atomic Patch
linaria Patch
@linaria/testkit Patch
linaria-website Patch
esbuild-example Patch
rollup-example Patch
vite-example Patch
webpack5-example Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Anber Anber merged commit 654d859 into callstack:master Jan 26, 2026
5 checks passed
@Anber Anber mentioned this pull request Jan 26, 2026
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