Skip to content

feat: add string literal unions typescript generic parsing and test#208

Merged
brendt merged 1 commit into
tempestphp:mainfrom
yilanboy:add-string-literal-unions-in-ts-generic
May 13, 2026
Merged

feat: add string literal unions typescript generic parsing and test#208
brendt merged 1 commit into
tempestphp:mainfrom
yilanboy:add-string-literal-unions-in-ts-generic

Conversation

@yilanboy
Copy link
Copy Markdown
Contributor

@yilanboy yilanboy commented May 7, 2026

Currently, I'm trying to add Svelte support to this package.

I really appreciate the TypeScript language support, so I can reuse it directly in Svelte.

I noticed that string-literal unions are missing from the generic pattern:

let filter: State<'all' | 'active' | 'done'> = 'all';

So I changed the generic regex pattern slightly:

// from
return '/(?<=\w)(?<match><[A-Z][\w\s,\.\[\]]*>)/';

// to
return '/(?<=\w)(?<match><[A-Z\'"][\w\s,\.\[\]\'"|]*>)/';

@brendt brendt merged commit dc14517 into tempestphp:main May 13, 2026
5 checks passed
@brendt
Copy link
Copy Markdown
Member

brendt commented May 13, 2026

Thanks!

@github-actions
Copy link
Copy Markdown

Benchmark Results

Comparison of add-string-literal-unions-in-ts-generic against main (b966e3d747888e94990934533d8ca4c368f667a9).

Open to see the benchmark results
benchmark subject set revs its mem_peak mode rstdev
HighlighterBench benchParse apache 100 5 2.042mb 0.00% 69.981977μs -0.27% ±0.58% +13.94%
HighlighterBench benchParse bash 100 5 2.072mb 0.00% 199.565245μs -0.15% ±0.61% -64.13%
HighlighterBench benchParse bbcode 100 5 2.041mb 0.00% 71.168728μs -0.93% ±0.69% -2.57%
HighlighterBench benchParse blade 100 5 2.645mb 0.00% 938.048552μs -0.58% ±1.15% +25.18%
HighlighterBench benchParse css 100 5 2.059mb 0.00% 135.861429μs +0.21% ±0.67% -6.32%
HighlighterBench benchParse diff 100 5 2.043mb 0.00% 25.854325μs -0.37% ±1.04% -4.05%
HighlighterBench benchParse dockerfile 100 5 2.043mb 0.00% 84.592211μs +0.38% ±0.56% -33.31%
HighlighterBench benchParse dotenv 100 5 2.044mb 0.00% 75.825577μs +0.26% ±0.52% +34.52%
HighlighterBench benchParse ellison 100 5 2.208mb 0.00% 317.514110μs +1.05% ±1.33% +260.10%
HighlighterBench benchParse gdscript 100 5 2.139mb 0.00% 318.357828μs +0.65% ±1.99% +255.32%
HighlighterBench benchParse html 100 5 2.063mb 0.00% 111.762329μs +0.35% ±0.38% +40.91%
HighlighterBench benchParse ini 100 5 2.048mb 0.00% 85.019159μs -0.70% ±1.30% +168.14%
HighlighterBench benchParse javascript 100 5 2.127mb 0.00% 259.184638μs -0.37% ±0.42% +103.27%
HighlighterBench benchParse json 100 5 2.102mb 0.00% 232.723836μs -0.01% ±0.49% -0.02%
HighlighterBench benchParse markdown 100 5 2.050mb 0.00% 72.424305μs -0.70% ±0.63% +81.22%
HighlighterBench benchParse nginx 100 5 2.114mb 0.00% 259.781233μs -0.35% ±0.30% -35.31%
HighlighterBench benchParse php 100 5 2.405mb 0.00% 719.442466μs +0.50% ±0.53% -70.21%
HighlighterBench benchParse python 100 5 2.303mb 0.00% 406.877397μs -0.28% ±0.67% +305.81%
HighlighterBench benchParse scss 100 5 2.075mb 0.00% 175.345851μs -0.18% ±0.45% +47.01%
HighlighterBench benchParse sql 100 5 2.074mb 0.00% 150.618415μs +0.32% ±0.22% -83.78%
HighlighterBench benchParse terminal 100 5 2.070mb 0.00% 189.329863μs +0.47% ±0.62% +137.89%
HighlighterBench benchParse terraform 100 5 2.074mb 0.00% 165.851918μs -0.29% ±0.75% -20.10%
HighlighterBench benchParse typescript 100 5 2.406mb +3.77% 233.561703μs +2.64% ±0.70% +90.27%
HighlighterBench benchParse twig 100 5 19.181mb 0.00% 1,349.509883μs +1.31% ±1.02% -35.67%
HighlighterBench benchParse xml 100 5 2.077mb 0.00% 175.495088μs -1.19% ±1.51% +188.57%
HighlighterBench benchParse yaml 100 5 2.135mb 0.00% 313.938748μs -0.18% ±0.47% +142.89%

Generated by phpbench against commit f5b62de

@brendt
Copy link
Copy Markdown
Member

brendt commented May 13, 2026

@coveralls
Copy link
Copy Markdown

Coverage Report for CI Build 25509195914

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Coverage remained the same at 94.41%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: 1 of 1 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 1932
Covered Lines: 1824
Line Coverage: 94.41%
Coverage Strength: 48.89 hits per line

💛 - Coveralls

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.

3 participants