Skip to content

Print remaining TS/V8 nodes; fix dropped enum members - #65

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

Print remaining TS/V8 nodes; fix dropped enum members#65
NullVoxPopuli merged 1 commit into
mainfrom
nvp/print-remaining-ts-nodes

Conversation

@NullVoxPopuli

Copy link
Copy Markdown
Owner

Summary

Closes the printer's coverage gap: diffing print's case labels against oxc-parser's + @glimmer/syntax's visitor-key maps (the same maps that generate the README node reference) showed every remaining node type is now handled.

Notable fix — silent enum data loss

Newer oxc nests enum members under a TSEnumBody child, but TSEnumDeclaration read node.members, so every enum printed empty:

enum Color { Red, Green, Blue }   ->   enum Color {\n\n}

No throw — members just vanished. Now read members through node.body (falling back to node.members for older oxc) and add a TSEnumBody case.

Remaining unprinted nodes (previously threw unsupported node type)

  • V8IntrinsicExpression%Name(args)
  • TSJSDocNullableType / TSJSDocNonNullableType?T / !T (postfix flips to T? / T!)
  • TSJSDocUnknownType?

These are exotic (V8 natives syntax; JSDoc-as-type), but handling them means the printer no longer throws on any node oxc/glimmer can emit.

Tests

  • print.test.js: TSEnumBody, TSEnumDeclaration with a body, JSDoc types, V8IntrinsicExpression.
  • parse-print-gts.test.js: parse→print enum (members preserved), via inline snapshots.
  • Full suite: 212 passing. oxlint + oxfmt --check + publint clean.

🤖 Generated with Claude Code

Closes the printer's coverage gap against oxc-parser's + @glimmer/syntax's
visitor-key maps — every node type now has a case.

The notable fix is silent data loss: newer oxc nests enum members under a
`TSEnumBody` child, but `TSEnumDeclaration` read `node.members`, so every
enum printed empty (`enum Color {}`). Read members through `node.body`
(falling back to `node.members` for older oxc) and add a `TSEnumBody` case.

Also add the last unprinted nodes, which previously threw `unsupported
node type`:
- V8IntrinsicExpression — `%Name(args)`
- TSJSDocNullableType / TSJSDocNonNullableType — `?T` / `!T` (postfix flips)
- TSJSDocUnknownType — `?`

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 376.29 µs 378.84 µs +0.7%
🔴 gts medium 51.61 ms 55.62 ms +7.8%
🟡 gts large 133.07 ms 129.03 ms -3.0%
🟡 gjs small 326.71 µs 332.25 µs +1.7%
🟢 gjs medium 64.64 ms 58.65 ms -9.3%
🟡 gjs large 218.30 ms 209.11 ms -4.2%
🟡 hbs small 84.33 µs 81.67 µs -3.1%
🟡 hbs medium 27.56 ms 26.50 ms -3.8%
🟡 hbs large 75.79 ms 73.84 ms -2.6%

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

Full mitata output
clk: ~2.48 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)          702.68 µs/iter 415.57 µs █                    
                      (327.24 µs … 8.36 ms)   6.55 ms █                    
                    ( 52.55 kb …   2.11 mb) 198.70 kb █▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁

gts small (experiment)       701.11 µs/iter 434.36 µs █                    
                      (325.64 µs … 9.56 ms)   5.76 ms █                    
                    ( 79.28 kb …   2.37 mb) 202.85 kb █▄▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁

                             ┌                                            ┐
                             ┌──┬                                         ╷
         gts small (control) │  │─────────────────────────────────────────┤
                             └──┴                                         ╵
                             ┌──┬                                   ╷
      gts small (experiment) │  │───────────────────────────────────┤
                             └──┴                                   ╵
                             └                                            ┘
                             325.64 µs           3.44 ms            6.55 ms

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

------------------------------------------- -------------------------------
gts medium (experiment)       66.54 ms/iter  66.25 ms   █                  
                     (42.96 ms … 148.52 ms)  90.02 ms ▅▅█▅ ▅▅ ▅ ▅      ▅  ▅
                    (803.06 kb …  13.12 mb)   4.29 mb ████▁██▁█▁█▁▁▁▁▁▁█▁▁█

gts medium (control)          68.22 ms/iter  54.88 ms    █                 
                     (42.51 ms … 175.01 ms) 105.19 ms   ▅█▅                
                    (729.60 kb …  12.32 mb)   3.62 mb ▇▁███▁▁▁▁▁▁▁▁▇▁▁▁▁▁▁▇

                             ┌                                            ┐
                             ╷   ┌────────────┬                ╷
     gts medium (experiment) ├───┤            │────────────────┤
                             ╵   └────────────┴                ╵
                             ╷    ┌────────────┬                          ╷
        gts medium (control) ├────┤            │──────────────────────────┤
                             ╵    └────────────┴                          ╵
                             └                                            ┘
                             42.51 ms          73.85 ms           105.19 ms

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

------------------------------------------- -------------------------------
gts large (control)          152.25 ms/iter 142.29 ms ██ █                 
                    (125.16 ms … 305.01 ms) 188.15 ms ██▅█▅▅▅             ▅
                    (  8.22 mb …  19.94 mb)   9.30 mb ███████▁▁▁▁▁▁▁▁▁▁▁▁▁█

gts large (experiment)       153.61 ms/iter 138.56 ms  █                   
                    (125.67 ms … 342.42 ms) 170.86 ms ▅█                   
                    (  8.31 mb …   9.36 mb)   8.80 mb ██▇▁▇▁▇▁▁▁▁▁▁▁▁▇▁▁▁▁▇

                             ┌                                            ┐
                             ╷ ┌────────────────┬                         ╷
         gts large (control) ├─┤                │─────────────────────────┤
                             ╵ └────────────────┴                         ╵
                             ╷ ┌─────────────────┬            ╷
      gts large (experiment) ├─┤                 │────────────┤
                             ╵ └─────────────────┴            ╵
                             └                                            ┘
                             125.16 ms         156.66 ms          188.15 ms

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

------------------------------------------- -------------------------------
gjs small (experiment)       652.75 µs/iter 377.52 µs █                    
                      (285.53 µs … 9.67 ms)   5.78 ms █                    
                    ( 39.23 kb …   2.45 mb) 193.25 kb █▃▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁

gjs small (control)          606.93 µs/iter 367.76 µs █                    
                      (284.53 µs … 8.48 ms)   5.24 ms █                    
                    (  6.78 kb …   2.19 mb) 187.86 kb █▃▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁

                             ┌                                            ┐
                             ┌──┬                                         ╷
      gjs small (experiment) │  │─────────────────────────────────────────┤
                             └──┴                                         ╵
                             ┌──┬                                     ╷
         gjs small (control) │  │─────────────────────────────────────┤
                             └──┴                                     ╵
                             └                                            ┘
                             284.53 µs           3.03 ms            5.78 ms

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

------------------------------------------- -------------------------------
gjs medium (control)          77.10 ms/iter  72.07 ms    █                 
                     (57.34 ms … 169.92 ms)  99.82 ms    █   █             
                    (  3.81 mb …  15.16 mb)   4.85 mb ████▁█▁█▁█▁▁▁▁▁▁▁▁▁▁█

gjs medium (experiment)       78.17 ms/iter  68.38 ms █                    
                     (56.27 ms … 201.65 ms) 117.56 ms █  ▂                 
                    (  3.68 mb …  15.34 mb)   4.98 mb █▆▁█▆▁▁▁▆▁▁▁▁▁▁▁▁▁▁▁▆

                             ┌                                            ┐
                              ╷  ┌──────────┬                ╷
        gjs medium (control)  ├──┤          │────────────────┤
                              ╵  └──────────┴                ╵
                             ┌───────────────┬                            ╷
     gjs medium (experiment) │               │────────────────────────────┤
                             └───────────────┴                            ╵
                             └                                            ┘
                             56.27 ms          86.91 ms           117.56 ms

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

------------------------------------------- -------------------------------
gjs large (experiment)       231.66 ms/iter 220.90 ms    █                 
                    (200.86 ms … 401.58 ms) 259.24 ms    █                 
                    (  6.86 mb …  20.61 mb)  11.08 mb ████▁███▁█▁▁▁▁▁▁▁▁▁▁█

gjs large (control)          246.99 ms/iter 235.44 ms ███                  
                    (210.97 ms … 429.71 ms) 283.79 ms ███ ▅▅ ▅         ▅  ▅
                    (  7.06 mb …  20.26 mb)  10.59 mb ███▁██▁█▁▁▁▁▁▁▁▁▁█▁▁█

                             ┌                                            ┐
                             ╷   ┌────────────┬              ╷
      gjs large (experiment) ├───┤            │──────────────┤
                             ╵   └────────────┴              ╵
                                  ╷ ┌─────────────────┬                   ╷
         gjs large (control)      ├─┤                 │───────────────────┤
                                  ╵ └─────────────────┴                   ╵
                             └                                            ┘
                             200.86 ms         242.32 ms          283.79 ms

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

------------------------------------------- -------------------------------
hbs small (control)          165.26 µs/iter  92.83 µs █                    
                      (80.83 µs … 13.21 ms)   3.47 ms █                    
                    (  8.32 kb …   1.87 mb) 100.66 kb █▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁

hbs small (experiment)       170.19 µs/iter  90.16 µs █                    
                      (78.32 µs … 13.03 ms)   3.46 ms █                    
                    ( 32.73 kb …   2.04 mb) 101.07 kb █▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁

                             ┌                                            ┐
                             ┌┬                                           ╷
         hbs small (control) ││───────────────────────────────────────────┤
                             └┴                                           ╵
                             ┌┬                                           ╷
      hbs small (experiment) ││───────────────────────────────────────────┤
                             └┴                                           ╵
                             └                                            ┘
                             78.32 µs            1.77 ms            3.47 ms

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

------------------------------------------- -------------------------------
hbs medium (experiment)       29.45 ms/iter  31.09 ms  █                   
                      (23.12 ms … 51.62 ms)  47.47 ms ▅█▅▅   ▅             
                    (  2.72 mb …   4.32 mb)   3.84 mb ████▇▁▇█▁▇▁▁▁▁▁▁▁▁▁▁▇

hbs medium (control)          30.74 ms/iter  31.49 ms █   █                
                      (23.76 ms … 63.64 ms)  43.09 ms ███ █   █            
                    (  3.10 mb …   4.17 mb)   3.73 mb ███▁█▁▁▁█▁▁▁█▁▁▁▁▁▁▁█

                             ┌                                            ┐
                             ╷ ┌─────────┬──┐                             ╷
     hbs medium (experiment) ├─┤         │  ├─────────────────────────────┤
                             ╵ └─────────┴──┘                             ╵
                              ╷ ┌──────────┬┐                     ╷
        hbs medium (control)  ├─┤          │├─────────────────────┤
                              ╵ └──────────┴┘                     ╵
                             └                                            ┘
                             23.12 ms           35.29 ms           47.47 ms

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

------------------------------------------- -------------------------------
hbs large (control)           91.58 ms/iter  90.81 ms   ██                 
                     (64.56 ms … 177.78 ms) 130.60 ms ▅▅██ ▅▅ ▅   ▅       ▅
                    (241.90 kb …  13.36 mb)   6.08 mb ████▁██▁█▁▁▁█▁▁▁▁▁▁▁█

hbs large (experiment)        95.88 ms/iter  78.02 ms   █                  
                     (66.10 ms … 242.17 ms) 157.46 ms  ▂█                  
                    (386.63 kb …  13.15 mb)   6.09 mb ▆██▆▁▆▁▁▁▁▁▁▁▁▁▁▁▁▁▁▆

                             ┌                                            ┐
                             ╷   ┌────────┬                  ╷
         hbs large (control) ├───┤        │──────────────────┤
                             ╵   └────────┴                  ╵
                              ╷  ┌──────────┬                             ╷
      hbs large (experiment)  ├──┤          │─────────────────────────────┤
                              ╵  └──────────┴                             ╵
                             └                                            ┘
                             64.56 ms          111.01 ms          157.46 ms

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

@NullVoxPopuli NullVoxPopuli added the bug Something isn't working label Jun 29, 2026
@NullVoxPopuli
NullVoxPopuli merged commit e657884 into main Jun 29, 2026
4 of 5 checks passed
@NullVoxPopuli
NullVoxPopuli deleted the nvp/print-remaining-ts-nodes branch June 29, 2026 19:29
@github-actions github-actions Bot mentioned this pull request 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