Skip to content

fix: generate React component declarations - #3104

Merged
chrisbbreuer merged 9 commits into
mainfrom
agent/react-component-declarations
Jul 21, 2026
Merged

fix: generate React component declarations#3104
chrisbbreuer merged 9 commits into
mainfrom
agent/react-component-declarations

Conversation

@chrisbbreuer

Copy link
Copy Markdown
Member

What changed

  • infer portable JSX.Element returns for function, arrow, nullable, fragment, member-tag, generic, and class components
  • preserve forwardRef, memo, lazy, namespace, named, and type-only React imports when emitted declarations reference them
  • scan JSX initializer nesting correctly so default exports and following declarations are not swallowed
  • support named and nested higher-order component wrappers without broadening ordinary call inference
  • cover both semantic inference and isolated-declarations paths, including the Zig emitter

Why

JSX brackets were previously interpreted as comparisons, arithmetic, or generic arguments. This produced incorrect number/boolean component returns, dropped wrapper imports, and could consume declarations following a JSX initializer.

Validation

  • 20 focused React declaration tests pass across the TypeScript and Zig engines
  • 313 Zig/Bun integration tests pass
  • 36 native type-inference tests pass
  • 26 native root scanner/emitter tests pass
  • 1,259 of 1,260 dtsx tests pass; the remaining pre-existing Vue test references the deleted packages/dtsx/test/fixtures/vue/NFTBurnButton.vue fixture
  • typecheck and build pass
  • lint reports zero errors and one pre-existing Markdown warning

@netlify

netlify Bot commented Jul 20, 2026

Copy link
Copy Markdown

Deploy Preview for dtsx failed. Why did it fail? →

Name Link
🔨 Latest commit aee2894
🔍 Latest deploy log https://app.netlify.com/projects/dtsx/deploys/6a5ecd6a2c10b5000803a16b

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Benchmark Results

Platform: linux x64 | Runtime: Bun 1.3.14 | Date: 2026-07-21

In-Process API — Cached

Smart caching (hash check + cache hit) for watch mode, incremental builds, and CI.

Tool Small (~50 lines) Medium (~100 lines) Large (~330 lines) XLarge (~1050 lines) XXLarge (~2000 lines) Huge (~5000 lines)
dtsx (cached) 3.7 µs 1.8 µs 1.5 µs 2.6 µs 5.9 µs 11.7 µs
zig-dtsx 14.4 µs (3.9x) 19.2 µs (10.8x) 62.7 µs (42.2x) 341.1 µs (132.8x) 357.6 µs (61.1x) 928.8 µs (79.2x)
oxc-transform 20.1 µs (5.4x) 64.2 µs (36.1x) 213.7 µs (143.9x) 1.10 ms (429.2x) 891.8 µs (152.4x) 2.22 ms (189.1x)
TypeScript 7 (CLI) 95.47 ms (25571.5x) 100.95 ms (56780.1x) 105.64 ms (71158.5x) 128.24 ms (49910.3x) 119.18 ms (20371.9x) 152.08 ms (12975.4x)

In-Process API — No Cache

Raw single-transform comparison (cache cleared every iteration).

Tool Small (~50 lines) Medium (~100 lines) Large (~330 lines) XLarge (~1050 lines) XXLarge (~2000 lines) Huge (~5000 lines)
zig-dtsx 14.4 µs (3.7x) 19.2 µs (7.4x) 62.7 µs (38.1x) 341.1 µs (112.6x) 357.6 µs (60.4x) 928.8 µs (72.2x)
oxc-transform 20.1 µs (5.1x) 64.2 µs (24.6x) 213.7 µs (129.9x) 1.10 ms (364.0x) 891.8 µs (150.5x) 2.22 ms (172.4x)
dtsx (no-cache) 3.9 µs 2.6 µs 1.6 µs 3.0 µs 5.9 µs 12.9 µs
TypeScript 7 (CLI) 95.47 ms (24460.6x) 100.95 ms (38754.8x) 105.64 ms (64226.4x) 128.24 ms (42332.4x) 119.18 ms (20118.7x) 152.08 ms (11829.5x)

Note: TypeScript 7 is CLI-only. Each measurement includes ~40ms process spawn overhead, so it is not directly comparable to the in-process tools above. It is reported separately from the in-process tools.

Multi-File Project

All tools processing files in-process sequentially.

Tool 50 files 100 files
zig-dtsx 5.78 ms (51.3x) 12.05 ms (20.1x)
dtsx 112.7 µs 598.4 µs
oxc-transform 17.27 ms (153.2x) 36.31 ms (60.7x)
tsc 537.79 ms (4771.6x) 1.03 s (1726.9x)

No previous benchmark found for regression comparison

zig-dtsx vs oxc-transform

Input Size zig-dtsx oxc-transform Speedup
Small (~50 lines) 14.4 µs 20.1 µs 🟢 1.39x
Medium (~100 lines) 19.2 µs 64.2 µs 🟢 3.33x
Large (~330 lines) 62.7 µs 213.7 µs 🟢 3.41x
XLarge (~1050 lines) 341.1 µs 1.10 ms 🟢 3.23x
XXLarge (~2000 lines) 357.6 µs 891.8 µs 🟢 2.49x
Huge (~5000 lines) 928.8 µs 2.22 ms 🟢 2.39x
Internal Benchmark Details

Extraction

Benchmark Avg Min Max Throughput Memory
Simple (0001.ts) 1.9 µs 942 ns 4.4 µs 380.7 M chars/s 0.0 MB
Medium (0002.ts) 6.3 µs 2.2 µs 13.0 µs 155.5 M chars/s 0.0 MB
Complex (0003.ts) 🏆 1.6 µs 911 ns 7.5 µs 821.6 M chars/s 0.0 MB
Very Complex (0005.ts) 7.6 µs 6.7 µs 11.4 µs 11.0 G chars/s 0.0 MB
Lodash-like (real-world) 4.4 µs 2.1 µs 20.5 µs 5.9 G chars/s 0.0 MB
React-like (real-world) 3.9 µs 3.4 µs 6.8 µs 8.5 G chars/s 0.0 MB

Synthetic

Benchmark Avg Min Max Throughput Memory
100 lines 🏆 1.6 µs 872 ns 19.2 µs 4.5 G chars/s 0.0 MB
500 lines 3.9 µs 2.6 µs 18.2 µs 9.3 G chars/s 0.0 MB
1000 lines 5.0 µs 4.5 µs 17.9 µs 14.3 G chars/s 0.0 MB
5000 lines 28.2 µs 22.2 µs 56.2 µs 13.2 G chars/s 0.0 MB
10000 lines 55.8 µs 47.3 µs 80.2 µs 13.4 G chars/s 0.0 MB

Memory

Benchmark Avg Min Max Throughput Memory
Large File Memory 🏆 18.62 ms 18.62 ms 18.62 ms 40.3 M chars/s 0.0 MB

Real-World

Benchmark Avg Min Max Throughput Memory
Lodash-like 🏆 3.3 µs 2.9 µs 7.4 µs 7.7 G chars/s 0.0 MB
React-like 4.6 µs 3.6 µs 12.7 µs 7.3 G chars/s 0.0 MB

Generation

Benchmark Avg Min Max Throughput Memory
Single File (100 lines) 🏆 1.14 ms 843.9 µs 1.69 ms 6.2 M chars/s 0.6 MB
Medium File (1000 lines) 3.72 ms 3.26 ms 4.20 ms 19.4 M chars/s 0.1 MB
Large File (5000 lines) 16.89 ms 14.14 ms 19.92 ms 22.1 M chars/s 15.1 MB

Phase Timing

File Phase Avg Time % of Total
500 lines Processing 1.38 ms ████████████████████ 99.5%
500 lines Extraction 5.3 µs █ 0.4%
500 lines Formatting 211 ns █ 0.0%
500 lines File Read 88 ns █ 0.0%
2000 lines Processing 3.49 ms ████████████████████ 99.6%
2000 lines Extraction 12.2 µs █ 0.3%
2000 lines Formatting 230 ns █ 0.0%
2000 lines File Read 131 ns █ 0.0%
5000 lines Processing 8.69 ms ████████████████████ 99.7%
5000 lines Extraction 28.7 µs █ 0.3%
5000 lines Formatting 237 ns █ 0.0%
5000 lines File Read 78 ns █ 0.0%
Metric Value
Total benchmarks 17
Avg time 2.38 ms
Total time 0.3 s

@chrisbbreuer
chrisbbreuer marked this pull request as ready for review July 21, 2026 01:37
@chrisbbreuer
chrisbbreuer merged commit 787d732 into main Jul 21, 2026
5 of 9 checks passed
@chrisbbreuer
chrisbbreuer deleted the agent/react-component-declarations branch July 21, 2026 01:40
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