feat(type-plus): add .$Fn to the two-input predicates - #705
Merged
Merged
Conversation
`Assignable`, `NotAssignable`, `Equal`, `HasKey` and `IsOptionalKey` take two inputs, and a type function has one. The entry being checked is the function's input; the other input is fixed as `.$Fn`'s first type parameter, ahead of the options. Closes #701 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: cbab0f0 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 #705 +/- ##
=========================================
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 3 of #701, the last part. Parts 1 (#703) and 2 (#704) are merged.
The parameter order follows the decision on the issue's open question: the function's input is the value being checked, and the other input is fixed as
.$Fn's first type parameter, ahead of$O.Changes
.$Fn<Fixed, $O>toAssignable,NotAssignable,Equal,HasKeyandIsOptionalKey.$Ois checked by$StrictOptions, as on the other.$Fns.guides/type-functions.mdxwith the shape and the reason only one of the two inputs can be the entry.Filterbenches forEqual.$Fn,Assignable.$FnandHasKey.$Fn.No reverse-direction variant (
$FnFrom), as decided. It can follow if a use case appears.Instantiation cost
Per
TuplePlus.Filtercall on a distinct 10-entry tuple, 100 uses:Filter+objectFilter+IsObject.$FnFilter+Equal.$FnFilter+Assignable.$FnFilter+HasKey.$FnEqual.$Fn<1>costs about the same asIsObject.$Fn, so an exact match is no more expensive than any other predicate function.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