feat(type-plus): add .$Fn to every one-input predicate - #704
Merged
Merged
Conversation
Each special-type, primitive, numeric and structure predicate, the Has* union predicates, and every IsNot* counterpart (including IsNotObject) now exposes `.$Fn<$O>`, the same shape as `IsObject.$Fn`, with a pinned `$Fn.Apply` example in its spec. The bench gains Filter runs for a few of them and for `IsNotX.$Fn` against `$Fn.Not<IsX.$Fn>`. Refs #701 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: cf966e7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #704 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 43 43
Lines 231 231
Branches 51 51
=========================================
Hits 231 231 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Part 2 of #701. Part 1 (the
ArrayPlus.Filterbug) is in #703. Part 3 (the two-input predicates) is waiting on a decision about parameter order.Changes
.$Fn<$O>to all 62 one-input predicates listed in feat(type-plus): complete type-function ($Fn) support across predicates and ArrayPlus.Filter #701. It has the same shape asIsObject.$Fn:readonly out: IsX<this['in'], $O>, with$Ochecked by$StrictOptions.HasNull,HasUndefined,HasVoid, and everyIsNot…counterpart, includingIsNotObject.IsNotX.$FnwrapsIsNotXdirectly, which is already the cheap inverse. It does not go through$Fn.Not..$Fnhas a TSDoc$Fn.Applyexample. The example is pinned in the predicate's existing spec, under adescribe('X.$Fn')block.guides/type-functions.mdx: the predicate list, two examples (checked against the compiler), and a cost note onIsNot…vs$Fn.Not.scripts/bench-instantiations.mjs:collection()now takes extra imports, and there are newFilterbenches.Instantiation cost
Per
TuplePlus.Filtercall on a distinct 10-entry tuple, 100 uses:Filter+objectFilter+IsObject.$FnFilter+IsNotObject.$FnFilter+Not<IsObject.$Fn>Filter+IsString.$FnFilter+IsNotString.$FnFilter+Not<IsString.$Fn>Filter+IsInteger.$FnFilter+IsUnion.$FnFilter+HasNull.$FnAn
IsNot…counterpart saves about 110 instantiations per call (about 10%) compared with$Fn.Not.Verification
pnpm --filter type-plus test:type.test:errorsmatches the snapshot on all five compilers.pnpm verifypasses. Locally,checkflagged only an untracked harness file that is not part of this PR.🤖 Generated with Claude Code