🌐 US-Proxy
class="logged-out env-production page-responsive" style="word-wrap: break-word;" >
Skip to content

Move simple Group A methods from CollectionImpl mixin into Collection.ts classes - #2192

Merged
jdeniau merged 1 commit into
6.xfrom
extract-mixin-simple-functions
May 28, 2026
Merged

Move simple Group A methods from CollectionImpl mixin into Collection.ts classes#2192
jdeniau merged 1 commit into
6.xfrom
extract-mixin-simple-functions

Conversation

@jdeniau

@jdeniau jdeniau commented May 27, 2026

Copy link
Copy Markdown
Member

Summary

First batch of methods migrated out of the CollectionImpl.js mixin() and into class declarations in Collection.ts. Targets the methods that have no dependency on Operations, 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-ifying CollectionImpl.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, update
  • IndexedCollectionImpl: findIndex, indexOf, first (override), last, get (override), has (override)

Signatures aligned with type-definitions/immutable.d.ts (NSV overloads on get/first/last, two-overload form for reduce/reduceRight, predicate: => boolean, iter: Iterable<V> for isSubset/isSuperset).

Side adjustments

  • src/utils/mixin.ts — switched from Object.keys to Object.getOwnPropertyNames (skipping constructor). Class methods are non-enumerable on the prototype, so the previous Object.keys no longer copied them into KeyedSeqImpl/IndexedSeqImpl/SetSeqImpl once the methods moved into the class.
  • src/Iterator.tsIterator<V> now declares implements IterableIterator<V, undefined>. It already returned this from [Symbol.iterator]() at runtime; the implements clause was just out of date and made subclasses unable to satisfy the new __iterator overloads.
  • src/Range.ts — added matching __iterator overloads, marked includes as override, removed a now-useless @ts-expect-error.
  • src/functional/get.ts, src/utils/deepEqual.ts — removed @ts-expect-error directives that became unused now that the class declares get/has.

Test plan

  • npx jest — 746/746 passing
  • npm run type-check:ts — clean
  • 0 test files modified

@jdeniau
jdeniau force-pushed the extract-mixin-simple-functions branch from 1d60377 to f998274 Compare May 27, 2026 07:05
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
jdeniau force-pushed the extract-mixin-simple-functions branch from f998274 to caa2c38 Compare May 28, 2026 21:30
@jdeniau
jdeniau merged commit 820e5f2 into 6.x May 28, 2026
5 checks passed
@jdeniau
jdeniau deleted the extract-mixin-simple-functions branch May 28, 2026 21:52
@jdeniau jdeniau added this to the 6.0 milestone May 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant