Skip to content

fix(@stdlib/random/streams/triangular): correct undefined RandomStream in TypeScript doctest examples#13234

Draft
Planeshifter wants to merge 2 commits into
developfrom
philipp/ci-fix-lint-random-files-triangular-doctest-2026-07-02
Draft

fix(@stdlib/random/streams/triangular): correct undefined RandomStream in TypeScript doctest examples#13234
Planeshifter wants to merge 2 commits into
developfrom
philipp/ci-fix-lint-random-files-triangular-doctest-2026-07-02

Conversation

@Planeshifter

Copy link
Copy Markdown
Member

Description

What is the purpose of this pull request?

This pull request:

  • fixes @example blocks in random/streams/triangular/docs/types/index.d.ts that reference the undefined runtime identifier RandomStream.

Failing run: https://github.com/stdlib-js/stdlib/actions/runs/28556769910

Symptom: Lint Random Files failed after its daily random file sample included this package's type declarations. The doctest runner throws RandomStream is not defined while executing the @example blocks.

Root cause: the module's default export is the lowercase randomStream constant; RandomStream exists only as a TypeScript type name (declare class RandomStream extends Readable). Several @example blocks in the declare class RandomStream and interface Constructor sections called new RandomStream(...) or RandomStream.factory(...) / RandomStream.objectMode(...) without referencing the actual runtime export, unlike sibling packages (e.g. random/streams/minstd) and this file's own final randomStream doc block.

Fix: add the missing var RandomStream = randomStream; alias before each new RandomStream(...) call and switch the static .factory/.objectMode calls to the lowercase randomStream export, matching the established sibling convention. Comment-only change; no type declarations were modified.

Related Issues

Does this pull request have any related issues?

This pull request has no related issues.

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.

Validation: cross-checked against random/streams/minstd/docs/types/index.d.ts line-by-line to confirm identical aliasing/lowercasing convention; confirmed factory/objectMode are declared members of interface Constructor so calling them on the lowercase randomStream export is valid; confirmed no other RandomStream./new RandomStream usages remain unaliased in the file; confirmed the diff touches only comment text, not type declarations. Three independent agent reviews (correctness, regression scope, style) all approved with no blocking findings.

Reviewer notes: the minstd reference file has the identical latent bug in its own destroy() example (new RandomStream() without a preceding alias), which this PR's target file no longer has. Worth a separate follow-up in minstd; out of scope here since lint_random_files did not flag it in this run.

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 pull request was prepared by Claude Code as part of an automated CI-failure investigation routine. Root cause was identified from job logs and the package's TypeScript declarations, cross-checked against the established sibling convention, and validated by three independent agent reviews.


@stdlib-js/reviewers


Generated by Claude Code

…am` in TypeScript doctest examples

The job `Lint Random Files` failed after its daily random file sample
included this package's type declarations, with the doctest runner
throwing `RandomStream is not defined` while executing the
`@example` blocks.

Root cause: the module's default export is the lowercase
`randomStream` constant; `RandomStream` only exists as a TypeScript
type name. Several `@example` blocks in the `declare class
RandomStream` and `interface Constructor` sections called
`new RandomStream(...)` or `RandomStream.factory(...)` /
`RandomStream.objectMode(...)` without first aliasing or referencing
the actual runtime export, unlike sibling packages (e.g.
`random/streams/minstd`) and this file's own final `randomStream`
doc block, which alias `RandomStream` to `randomStream` before `new`
calls and call `.factory`/`.objectMode` on the lowercase export
directly.

This commit adds the missing `var RandomStream = randomStream;`
alias before each `new RandomStream(...)` call and switches the
static `.factory`/`.objectMode` calls to the lowercase `randomStream`
export, matching the established sibling convention. Classified as
`fix` rather than `docs` per this repo's commit taxonomy, since
TypeScript declaration files are part of a package's public API.

Ref: https://github.com/stdlib-js/stdlib/actions/runs/28556769910
@stdlib-bot

stdlib-bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
random/streams/triangular $\\color{green}838/838$
$\\color{green}+100.00\\%$
$\\color{green}107/107$
$\\color{green}+100.00\\%$
$\\color{green}15/15$
$\\color{green}+100.00\\%$
$\\color{green}838/838$
$\\color{green}+100.00\\%$

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

…pectError` blocks

`Lint Changed Files` failed on this PR with
`@typescript-eslint/no-unused-vars` on `test.ts`, which the workflow
also lints whenever the corresponding `index.d.ts` changes. The
flagged `const s1 = new RandomStream(...)` bindings exist only to
satisfy `$ExpectError` (the compiler error is expected at the `new`
call itself), so the assignment is unnecessary — `new RandomStream(...)`
is a valid standalone expression statement and triggers the identical
compiler diagnostic on the same line. Dropping the unused bindings
fixes the lint error without changing what is being type-tested.

This pattern is pre-existing and widespread across sibling
`random/streams/*` packages; only this file was touched, since it is
the one flagged by CI.
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.

3 participants