Move simple Group A methods from CollectionImpl mixin into Collection.ts classes - #2192
Merged
Conversation
jdeniau
force-pushed
the
extract-mixin-simple-functions
branch
from
May 27, 2026 07:05
1d60377 to
f998274
Compare
First batch of methods that have no dependency on Operations/Map/List/Set moved into class declarations, alongside small fixes to make TS happy. Methods migrated (all "Group A" - self-contained): - CollectionImpl: values, some, forEach, findEntry, find, findKey, keyOf, first, get, has, includes, isEmpty, isSubset, isSuperset, join, reduce, reduceRight, update - IndexedCollectionImpl: findIndex, indexOf, first, last, get, has Signatures aligned with type-definitions/immutable.d.ts (NSV overloads on get/first/last, reduce/reduceRight overloads, predicate: => boolean). Side adjustments: - utils/mixin.ts: Object.getOwnPropertyNames + skip "constructor" so the mixin propagates non-enumerable class methods to Seq subclasses (the existing Object.keys ignored class methods). - Iterator: declare IterableIterator<V> (was already structurally one via [Symbol.iterator] returning this) so subclasses can satisfy the new __iterator overloads. - Range: add matching __iterator overloads, mark includes as override, drop now-useless @ts-expect-error. - functional/get.ts, utils/deepEqual.ts: drop @ts-expect-error directives that became unused now that the class declares get/has. 746/746 tests pass, type-check:ts green, 0 tests modified.
jdeniau
force-pushed
the
extract-mixin-simple-functions
branch
from
May 28, 2026 21:30
f998274 to
caa2c38
Compare
4 tasks
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
First batch of methods migrated out of the
CollectionImpl.jsmixin()and into class declarations inCollection.ts. Targets the methods that have no dependency onOperations,Map,List,Set,Stack,OrderedMap,OrderedSet— i.e. the ones that don't trigger circular import problems.Goal: reduce the surface area of the runtime
mixin()step, which is the main obstacle to fully TS-ifyingCollectionImpl.js. Subsequent PRs will tackle the Operations-dependent group and finally the 6 conversion methods (toMap/toList/…) via a late-binding registry.What moved
CollectionImpl:values,some,forEach,findEntry,find,findKey,keyOf,first,get,has,includes,isEmpty,isSubset,isSuperset,join,reduce,reduceRight,updateIndexedCollectionImpl:findIndex,indexOf,first(override),last,get(override),has(override)Signatures aligned with
type-definitions/immutable.d.ts(NSV overloads onget/first/last, two-overload form forreduce/reduceRight,predicate: => boolean,iter: Iterable<V>forisSubset/isSuperset).Side adjustments
src/utils/mixin.ts— switched fromObject.keystoObject.getOwnPropertyNames(skippingconstructor). Class methods are non-enumerable on the prototype, so the previousObject.keysno longer copied them intoKeyedSeqImpl/IndexedSeqImpl/SetSeqImplonce the methods moved into the class.src/Iterator.ts—Iterator<V>now declaresimplements IterableIterator<V, undefined>. It already returnedthisfrom[Symbol.iterator]()at runtime; theimplementsclause was just out of date and made subclasses unable to satisfy the new__iteratoroverloads.src/Range.ts— added matching__iteratoroverloads, markedincludesasoverride, removed a now-useless@ts-expect-error.src/functional/get.ts,src/utils/deepEqual.ts— removed@ts-expect-errordirectives that became unused now that the class declaresget/has.Test plan
npx jest— 746/746 passingnpm run type-check:ts— clean