Skip to content

fix(react): reduce polymorphic as type instantiations#1490

Merged
Anber merged 1 commit into
callstack:masterfrom
Anber:fix/1489-styled-as-type-perf
Jul 20, 2026
Merged

fix(react): reduce polymorphic as type instantiations#1490
Anber merged 1 commit into
callstack:masterfrom
Anber:fix/1489-styled-as-type-perf

Conversation

@Anber

@Anber Anber commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • defer JSX.IntrinsicElements[TAs] expansion until as resolves to a concrete intrinsic tag
  • prevent target props from widening TAs
  • preserve intrinsic prop inference for usages such as as="a"
  • add negative tests for props that do not belong to the selected tag

Why

@linaria/react@8.1.0 made every styled component expose a generic overload indexed by the full JSX.IntrinsicElements map. In styled-heavy React 19 projects, TypeScript can materialize that map for every component, causing millions of type instantiations and out-of-memory failures.

The new helper avoids expanding the map while TAs is still unresolved. Once as is a concrete intrinsic tag, its corresponding props are selected normally.

Fixes #1489.

Validation

  • pnpm check:all

@changeset-bot

changeset-bot Bot commented Jul 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 76517ff

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/babel-plugin-interop Patch
@linaria/core Patch
@linaria/postcss-linaria Patch
@linaria/server Patch
@linaria/stylelint Patch
@linaria/stylelint-config-standard-linaria Patch
linaria 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 marked this pull request as ready for review July 20, 2026 13:51
@Anber Anber self-assigned this Jul 20, 2026
@Anber
Anber merged commit 08bb5fd into callstack:master Jul 20, 2026
5 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.

Bug: styled as-prop typings in v8 cause a ~23× TypeScript instantiation blow-up (OOM / very slow tsc)

1 participant