Skip to content

Add print support for TSParenthesizedType - #63

Merged
NullVoxPopuli merged 1 commit into
mainfrom
nvp/print-ts-parenthesized-type
Jun 29, 2026
Merged

Add print support for TSParenthesizedType#63
NullVoxPopuli merged 1 commit into
mainfrom
nvp/print-ts-parenthesized-type

Conversation

@NullVoxPopuli

Copy link
Copy Markdown
Owner

Summary

print threw unsupported node type 'TSParenthesizedType' on a parenthesized type such as type X = (A | B)[];. oxc-parser preserves the parens as a TSParenthesizedType node (single typeAnnotation child) — the type-level analog of ParenthesizedExpression — but the printer had no case, so it hit the unsupported node type throw.

Change

Add the case: (${print(node.typeAnnotation)}).

Tests

  • print.test.js: TSParenthesizedType wrapping a union.
  • parse-print-gts.test.js: round-trip of type X = (A | B)[];.
  • Full suite: 207 passing. oxlint + oxfmt --check + publint clean.

🤖 Generated with Claude Code

`print` threw `unsupported node type 'TSParenthesizedType'` on a
parenthesized type like `type X = (A | B)[];` — oxc-parser preserves the
parens as a TSParenthesizedType (single `typeAnnotation` child), the
type-level analog of ParenthesizedExpression, but the printer had no case.

Print it as `(${typeAnnotation})`. Covered by a unit test and a
parse+print round-trip.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

🏎️ Benchmark Comparison

Benchmark Control (p50) Experiment (p50) Δ
gts small 364.75 µs 367.00 µs +0.6%
🔴 gts medium 47.66 ms 55.00 ms +15.4%
🟡 gts large 131.01 ms 129.60 ms -1.1%
🟡 gjs small 322.69 µs 329.39 µs +2.1%
🟡 gjs medium 66.38 ms 65.12 ms -1.9%
🟡 gjs large 220.71 ms 223.23 ms +1.1%
🟡 hbs small 83.17 µs 84.35 µs +1.4%
🔴 hbs medium 25.77 ms 29.23 ms +13.4%
🟡 hbs large 78.01 ms 74.19 ms -4.9%

🟢 faster · 🔴 slower · 🟡 within 5% · ⚪ within 1%

Full mitata output
clk: ~2.47 GHz
cpu: AMD EPYC 7763 64-Core Processor
runtime: node 22.23.0 (x64-linux)

benchmark                   avg (min … max) p75 / p99    (min … top 1%)
------------------------------------------- -------------------------------
gts small (control)          642.61 µs/iter 398.28 µs █                    
                     (324.02 µs … 10.01 ms)   5.87 ms █                    
                    (  3.17 kb …   2.17 mb) 196.70 kb █▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁

gts small (experiment)       636.02 µs/iter 403.45 µs █                    
                      (322.17 µs … 8.02 ms)   5.32 ms █                    
                    ( 53.74 kb …   3.08 mb) 195.57 kb █▃▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁

                             ┌                                            ┐
                             ┌──┬                                         ╷
         gts small (control) │  │─────────────────────────────────────────┤
                             └──┴                                         ╵
                             ┌──┬                                     ╷
      gts small (experiment) │  │─────────────────────────────────────┤
                             └──┴                                     ╵
                             └                                            ┘
                             322.17 µs           3.10 ms            5.87 ms

summary
  gts small (experiment)
   1.01x faster than gts small (control)

------------------------------------------- -------------------------------
gts medium (experiment)       65.05 ms/iter  64.17 ms          █           
                     (41.74 ms … 130.09 ms)  89.79 ms   █      █           
                    (844.69 kb …  12.41 mb)   3.95 mb ████▁▁█▁▁█▁▁▁▁▁▁▁▁▁██

gts medium (control)          69.18 ms/iter  61.09 ms  █                   
                     (42.45 ms … 183.69 ms) 125.36 ms ▂█                   
                    (811.49 kb …  13.66 mb)   4.27 mb ██▆▁▆▁▁▁▁▁▆▁▁▁▁▁▁▁▁▁▆

                             ┌                                            ┐
                             ╷ ┌──────────┬            ╷
     gts medium (experiment) ├─┤          │────────────┤
                             ╵ └──────────┴            ╵
                             ╷ ┌────────────┬                             ╷
        gts medium (control) ├─┤            │─────────────────────────────┤
                             ╵ └────────────┴                             ╵
                             └                                            ┘
                             41.74 ms          83.55 ms           125.36 ms

summary
  gts medium (experiment)
   1.06x faster than gts medium (control)

------------------------------------------- -------------------------------
gts large (control)          148.74 ms/iter 139.17 ms █                    
                    (124.76 ms … 288.19 ms) 183.45 ms █ ██                 
                    (  7.19 mb …  19.71 mb)   9.03 mb ████▁██▁▁▁▁▁▁▁▁▁▁▁▁▁█

gts large (experiment)       152.45 ms/iter 134.28 ms █                    
                    (125.78 ms … 330.49 ms) 176.53 ms ████                 
                    (  8.32 mb …   9.41 mb)   8.81 mb ████▁▁▁▁▁▁▁▁▁▁█▁▁▁▁▁█

                             ┌                                            ┐
                             ╷┌────────────────┬                          ╷
         gts large (control) ├┤                │──────────────────────────┤
                             ╵└────────────────┴                          ╵
                              ┌───────────────────┬                  ╷
      gts large (experiment)  │                   │──────────────────┤
                              └───────────────────┴                  ╵
                             └                                            ┘
                             124.76 ms         154.11 ms          183.45 ms

summary
  gts large (control)
   1.02x faster than gts large (experiment)

------------------------------------------- -------------------------------
gjs small (experiment)       637.39 µs/iter 374.23 µs █                    
                     (282.64 µs … 11.00 ms)   5.53 ms █                    
                    ( 68.17 kb …   2.14 mb) 188.16 kb █▃▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁

gjs small (control)          604.41 µs/iter 359.76 µs █                    
                     (283.23 µs … 12.96 ms)   5.61 ms █                    
                    ( 49.11 kb …   3.34 mb) 185.48 kb █▃▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁

                             ┌                                            ┐
                             ┌──┬                                        ╷
      gjs small (experiment) │  │────────────────────────────────────────┤
                             └──┴                                        ╵
                             ┌──┬                                         ╷
         gjs small (control) │  │─────────────────────────────────────────┤
                             └──┴                                         ╵
                             └                                            ┘
                             282.64 µs           2.94 ms            5.61 ms

summary
  gjs small (control)
   1.05x faster than gjs small (experiment)

------------------------------------------- -------------------------------
gjs medium (control)          78.33 ms/iter  74.06 ms █ █                  
                     (57.94 ms … 173.66 ms)  99.16 ms █ █▅▅ ▅▅▅ ▅         ▅
                    (  3.71 mb …  15.14 mb)   5.45 mb █▁███▁███▁█▁▁▁▁▁▁▁▁▁█

gjs medium (experiment)       81.61 ms/iter  70.71 ms █                    
                     (58.07 ms … 186.98 ms) 142.69 ms ████                 
                    (  4.14 mb …  14.01 mb)   5.53 mb ████▁▁█▁▁▁▁▁▁▁▁▁▁▁▁▁█

                             ┌                                            ┐
                             ╷ ┌────────┬          ╷
        gjs medium (control) ├─┤        │──────────┤
                             ╵ └────────┴          ╵
                             ╷┌───────────┬                               ╷
     gjs medium (experiment) ├┤           │───────────────────────────────┤
                             ╵└───────────┴                               ╵
                             └                                            ┘
                             57.94 ms          100.32 ms          142.69 ms

summary
  gjs medium (control)
   1.04x faster than gjs medium (experiment)

------------------------------------------- -------------------------------
gjs large (experiment)       241.11 ms/iter 234.02 ms █ █      █           
                    (212.09 ms … 409.69 ms) 261.46 ms █▅█  ▅▅▅ █          ▅
                    (  6.87 mb …  20.61 mb)  11.02 mb ███▁▁███▁█▁▁▁▁▁▁▁▁▁▁█

gjs large (control)          240.87 ms/iter 226.38 ms      █               
                    (215.46 ms … 433.01 ms) 238.14 ms    █ █               
                    (  9.15 mb …  22.41 mb)  10.61 mb █▁████▁▁▁▁█▁▁▁▁▁▁▁▁██

                             ┌                                            ┐
                             ╷ ┌───────────────────────┬                  ╷
      gjs large (experiment) ├─┤                       │──────────────────┤
                             ╵ └───────────────────────┴                  ╵
                                ╷   ┌────────────────╷─┬
         gjs large (control)    ├───┤                ┤ │
                                ╵   └────────────────╵─┴
                             └                                            ┘
                             212.09 ms         236.77 ms          261.46 ms

summary
  gjs large (control)
   1x faster than gjs large (experiment)

------------------------------------------- -------------------------------
hbs small (control)          185.17 µs/iter  92.97 µs █                    
                      (78.51 µs … 12.49 ms)   5.49 ms █                    
                    ( 59.74 kb …   1.73 mb) 101.18 kb █▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁

hbs small (experiment)       187.55 µs/iter  96.72 µs █                    
                      (79.34 µs … 12.40 ms)   5.49 ms █                    
                    ( 53.66 kb …   2.65 mb) 101.96 kb █▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁

                             ┌                                            ┐
                             ┌┬                                           ╷
         hbs small (control) ││───────────────────────────────────────────┤
                             └┴                                           ╵
                             ┌┬                                           ╷
      hbs small (experiment) ││───────────────────────────────────────────┤
                             └┴                                           ╵
                             └                                            ┘
                             78.51 µs            2.79 ms            5.49 ms

summary
  hbs small (control)
   1.01x faster than hbs small (experiment)

------------------------------------------- -------------------------------
hbs medium (experiment)       32.19 ms/iter  34.09 ms █                    
                      (25.35 ms … 60.55 ms)  39.78 ms █    ▂      ▂        
                    (  3.28 mb …   4.27 mb)   3.85 mb █▁▁▆▁█▆▁▁▁▁▁█▁▆▁▆▁▁▁▆

hbs medium (control)          32.19 ms/iter  35.66 ms █                    
                      (23.57 ms … 71.57 ms)  46.14 ms █          ▇         
                    (  3.09 mb …   4.67 mb)   3.95 mb █▆▆▆▆▁▁▁▁▁▁█▁▁▁▁▁▁▁▁▆

                             ┌                                            ┐
                                 ┌────────────┬───┐          ╷
     hbs medium (experiment)     │            │   ├──────────┤
                                 └────────────┴───┘          ╵
                             ╷┌───────────────┬──────┐                    ╷
        hbs medium (control) ├┤               │      ├────────────────────┤
                             ╵└───────────────┴──────┘                    ╵
                             └                                            ┘
                             23.57 ms           34.85 ms           46.14 ms

summary
  hbs medium (experiment)
   1x faster than hbs medium (control)

------------------------------------------- -------------------------------
hbs large (control)           94.58 ms/iter  91.04 ms   █ █                
                     (61.86 ms … 185.69 ms) 144.04 ms ▅ █▅█▅▅▅    ▅       ▅
                    (  1.14 mb …  13.35 mb)   6.66 mb █▁██████▁▁▁▁█▁▁▁▁▁▁▁█

hbs large (experiment)        96.00 ms/iter  82.62 ms   █                  
                     (66.84 ms … 255.89 ms) 135.48 ms   █▅                 
                    (  1.09 mb …  13.52 mb)   6.72 mb ▇▇██▁▇▁▁▇▁▁▁▁▁▁▁▁▁▁▁▇

                             ┌                                            ┐
                             ╷    ┌────────────┬                          ╷
         hbs large (control) ├────┤            │──────────────────────────┤
                             ╵    └────────────┴                          ╵
                                ╷  ┌────────────┬                    ╷
      hbs large (experiment)    ├──┤            │────────────────────┤
                                ╵  └────────────┴                    ╵
                             └                                            ┘
                             61.86 ms          102.95 ms          144.04 ms

summary
  hbs large (control)
   1.02x faster than hbs large (experiment)

@NullVoxPopuli
NullVoxPopuli merged commit f50c4d6 into main Jun 29, 2026
4 checks passed
@NullVoxPopuli
NullVoxPopuli deleted the nvp/print-ts-parenthesized-type branch June 29, 2026 19:21
@github-actions github-actions Bot mentioned this pull request Jun 29, 2026
@NullVoxPopuli NullVoxPopuli added the bug Something isn't working label Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant