fix(types): TrainCase should insert joiner between tokens, not as prefix#117
fix(types): TrainCase should insert joiner between tokens, not as prefix#117guoyangzhen wants to merge 1 commit intounjs:mainfrom
Conversation
Fixes unjs#110 The TrainCase type was passing the joiner as the Accumulator parameter to CapitalizedWords, causing it to be prepended to the output (e.g. "-HelloWorld" instead of "Hello-World"). Added JoinCapitalizedWords type that properly inserts the joiner between capitalized tokens, following the same pattern as JoinLowercaseWords.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughUpdated the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip You can validate your CodeRabbit configuration file in your editor.If your editor has YAML language server, you can enable auto-completion and validation by adding |
Fixes #110
Problem
The
TrainCasetype passes theJoinerparameter as theAccumulatortoCapitalizedWords, causing the joiner to be prepended to the output instead of inserted between tokens.Root Cause
CapitalizedWordsuses the second parameter as an initial accumulator value.TrainCasepassesJoineras theAccumulator, resulting in${"-"}${Capitalize<"hello">}="-Hello".Fix
Added
JoinCapitalizedWordstype that properly inserts the joiner between tokens, following the same pattern as the existingJoinLowercaseWords. The first word has no prefix, subsequent words are preceded by the joiner.Verification
The runtime
trainCasefunction already works correctly (uses.join("-")). This fix aligns the type-level behavior with the runtime behavior.Summary by CodeRabbit