feat: add [String] and [Number] option types - #396
Merged
Conversation
…options The `Array` type splits every value by commas, which mangles values that carry commas of their own - a brace glob or a media query list. The list types take the argument as it is and collect the repeated options instead.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #396 +/- ##
==========================================
+ Coverage 98.34% 98.47% +0.12%
==========================================
Files 5 5
Lines 121 131 +10
Branches 31 35 +4
==========================================
+ Hits 119 129 +10
Misses 2 2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a list form to
option:[String]and[Number]take the next argument as a whole and collect repeated options, instead of splitting it.Why
Arraysplits every value by commas, so a value that carries commas of its own does not survive:Both are ordinary inputs — a brace glob and a media query list — and there was no way to opt out of the splitting:
Stringkeeps the value whole but silently drops all but the last repeated option.A consumer can work around it by re-joining and re-splitting brace-aware, but that only covers braces, and the alias plus camelCase/kebab-case matching lives in the non-exported
matchArgName, so a custom reader means forking that part.What changed
ListConstructorandOptionConstructortypes, plus the two branches inOptionValueType—[String]infersstring[],[Number]infersnumber[];Array.isArray(type)branch inoption;PrimitiveConstructoris untouched, so nothing that used it before changes.The pinned bundle size moved by 5 B (850 B → 855 B), so
.size-limit.jsonis re-pinned to 900 B on the 0.05 kB step.