fix(type): add number.finite keyword to reject Infinity and NaN#1605
Open
WolfieLeader wants to merge 6 commits intoarktypeio:mainfrom
Open
fix(type): add number.finite keyword to reject Infinity and NaN#1605WolfieLeader wants to merge 6 commits intoarktypeio:mainfrom
WolfieLeader wants to merge 6 commits intoarktypeio:mainfrom
Conversation
Matches the pattern used by number.safe. min/max bounds are composable, JIT-compiled, and introspectable by the fast-check arbitrary generator.
Contributor
There was a problem hiding this comment.
Clean implementation that mirrors the number.safe pattern. One required change: allConfig.ts must be regenerated to include "number.finite", otherwise the testAllConfig integration test will fail (pnpm testRepo → pnpm testIntegration → pnpm testAllConfig).
| root: intrinsic.number, | ||
| integer, | ||
| epoch, | ||
| finite, |
Contributor
There was a problem hiding this comment.
allConfig.ts is a checked-in generated file that the testAllConfig integration test uses to verify every keyword has a "configured" description. It currently does not include "number.finite", so the test will fail.
Run the generator to update it:
pnpm tsx ark/type/__tests__/integration/generateAllConfig.tsThe generator uses JSON.stringify with spaces but the project enforces tabs via prettier.
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.

Summary
Closes #1598
Adds
number.finitekeyword that rejectsNaN,Infinity, and-Infinity. MatchesNumber.isFinite()semantics.Implementation follows the
number.safepattern exactly:numberAllowsNaN: falseon the domain node (rejects NaN)min/maxbounds at±Number.MAX_VALUEwith custommeta: "a finite number"(rejects ±Infinity with a clear error message)Using
min/maxrather than a predicate ensures the constraint is composable (intersects with user bounds), JIT-compiled, introspectable, and compatible with the fast-check arbitrary generator.Error messages:
Infinity→"must be a finite number (was Infinity)"-Infinity→"must be a finite number (was -Infinity)"NaN→"must be a number (was NaN)"(domain-level rejection)Test plan
pnpm prCheckspasses (format, lint, typecheck, full test suite)