Skip to content

Conversation

@nvie
Copy link

@nvie nvie commented Feb 10, 2026

This PR:

  • Fixes coerce(): it was converting any digit-starting string to Number(value), even when the result is NaN (e.g. "3.7.1", "1abc")
  • Added an isNaN guard so invalid conversions fall back to the original string

For example:

  • parse(["3.7.1"]){ _: ["3.7.1"] } (was { _: [NaN] })
  • parse(["1abc"]){ _: ["1abc"] } (was { _: [NaN] })
  • parse(["--version", "3.7.1"]){ version: "3.7.1" } (was { version: NaN })
  • Existing numeric coercion unchanged: "42"42, ".5"0.5, "3.14"3.14

Strings like "3.7.1" or "1abc" start with a digit but aren't valid
numbers. The coerce function was blindly returning Number(value),
producing NaN. Now it checks isNaN before returning the numeric result,
falling back to the original string.
@changeset-bot
Copy link

changeset-bot bot commented Feb 10, 2026

🦋 Changeset detected

Latest commit: 5f88b66

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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.

1 participant