Skip to content

fix(positive-integer): 🐛 Extend PositiveNumber instead of Integer - #100

Merged
haskou merged 1 commit into
masterfrom
fix/positive-integer-extends-positive-number
Oct 13, 2026
Merged

haskou merged 1 commit into
masterfrom
fix/positive-integer-extends-positive-number

Conversation

@haskou

@haskou haskou commented Oct 13, 2026

Copy link
Copy Markdown
Owner

What

PositiveInteger now extends PositiveNumber instead of Integer. PositiveNumber validates the sign and PositiveInteger adds the integer check (InvalidIntegerError).

Behaviour changes

  • new PositiveInteger(1) instanceof Integer is now false. Code typing a parameter as Integer and passing a PositiveInteger will stop compiling. FileSize is the only consumer in this repo and is unaffected.
  • The sign is validated first, so new PositiveInteger(-0.5) throws InvalidPositiveNumberError (it used to throw InvalidIntegerError).
  • The % 1 === 0 check now exists in both Integer and PositiveInteger.

Docs and tests

docs/reference/positive-integer.md updated (signature and notes). Spec now asserts inheritance from PositiveNumber, no inheritance from Integer, and the new error for -0.5.

Verification

yarn test (717 tests) and yarn build pass. Coverage stays at 100%.

@codecov

codecov Bot commented Oct 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@haskou
haskou merged commit 265e908 into master Oct 13, 2026
3 checks passed
@haskou
haskou deleted the fix/positive-integer-extends-positive-number branch October 13, 2026 09:10
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