Skip to content

refactor: use shared Iterator type in iter/cugmean#12497

Draft
Planeshifter wants to merge 1 commit into
developfrom
philipp/iter-cugmean-iterator-import
Draft

refactor: use shared Iterator type in iter/cugmean#12497
Planeshifter wants to merge 1 commit into
developfrom
philipp/iter-cugmean-iterator-import

Conversation

@Planeshifter
Copy link
Copy Markdown
Member

@Planeshifter Planeshifter commented Jun 3, 2026

Description

What is the purpose of this pull request?

This pull request replaces the local Iterator union type (Iter or IterableIterator) with the direct import { Iterator } from "@stdlib/types/iter" used by all eight sibling iter/cu*mean packages (e.g. cumean), which share an identical declaration shape and type test.

This is part of a series of follow-up PRs addressing findings from a TypeScript declaration audit of the stats namespace (documentation-only fixes landed separately in #12482).

Related Issues

Does this pull request have any related issues?

No.

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

No.

Checklist

Please ensure the following tasks are completed before submitting this pull request.

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of AI assistance?

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Disclosure

This change was surfaced by a Claude Code audit of the stats namespace TypeScript declarations. The fix was verified against the implementation and declaration test before submission, and reviewed by myself.


@stdlib-js/reviewers

---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: passed
  - task: lint_markdown_pkg_readmes
    status: na
  - task: lint_markdown_docs
    status: na
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: na
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: na
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: passed
  - task: lint_typescript_tests
    status: passed
  - task: lint_license_headers
    status: passed
---
@Planeshifter Planeshifter requested a review from a team June 3, 2026 05:08
@stdlib-bot
Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/iter/cugmean $\color{green}198/198$
$\color{green}+100.00\%$
$\color{green}18/18$
$\color{green}+100.00\%$
$\color{green}4/4$
$\color{green}+100.00\%$
$\color{green}198/198$
$\color{green}+100.00\%$

The above coverage report was generated for the changes in this PR.

@Planeshifter Planeshifter marked this pull request as draft June 3, 2026 05:22
@stdlib-bot stdlib-bot added Statistics Issue or pull request related to statistical functionality. Needs Review A pull request which needs code review. and removed Needs Review A pull request which needs code review. labels Jun 3, 2026
@@ -20,10 +20,7 @@

/// <reference types="@stdlib/types"/>

import { Iterator as Iter, IterableIterator } from '@stdlib/types/iter';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't quite what we want. We can actually improve type specificity here and in other similar packages in a few ways:

  1. The union is correct insofar as the function accepts both iterators and iterable iterators.
  2. The output iterator should be typed, as it always returns numbers.
  3. We should likely type the input iterator, as well, since it should return numbers.
  4. Via the union, we can use generics where T extends the union and we return T. That should cover both the iterator and iterable iterator behavior mentioned in the notes for those environments supporting Symbol.iterator.

@kgryte kgryte added the Needs Changes Pull request which needs changes before being merged. label Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Changes Pull request which needs changes before being merged. Statistics Issue or pull request related to statistical functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants