Skip to content

fix: narrow flatten() type#21

Merged
delacry merged 1 commit into
noctud:0.1.xfrom
nikophil:worktree-narrow-flatten-return-type
Jul 25, 2026
Merged

fix: narrow flatten() type#21
delacry merged 1 commit into
noctud:0.1.xfrom
nikophil:worktree-narrow-flatten-return-type

Conversation

@nikophil

Copy link
Copy Markdown
Contributor

if the type of the "sub-items" is known, then flatten() can return something more precise than Collection<mixed>

@codecov

codecov Bot commented Jul 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@delacry

delacry commented Jul 25, 2026

Copy link
Copy Markdown
Member

Oh, so you fixed it 😄 I just created issue few minutes ago #25 because I saw a comment in some of your previous PR regarding the Collection<mixed> type, thanks!

@delacry
delacry merged commit b424d15 into noctud:0.1.x Jul 25, 2026
6 checks passed
delacry added a commit that referenced this pull request Jul 25, 2026
Update the API reference for narrowing that landed in #15, #17, #18,
#19, #21 and #22: flatten(), filterNotNull(),
Map::filterValuesNotNull(), countWhere(), Collection::sum() and
Map::toArray().

Compact types are inlined in the signature (countWhere(): int<0, max>);
conditional ones are described in prose instead, matching how sum() and
intersect() are already documented.

Also fix the flatten() assertion in TransformTypeTest, which still
expected Collection<mixed> and has failed on 0.1.x since #21.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants