docs: fix assign examples in random/array TypeScript declarations#12738
Merged
Conversation
The `assign` method `@example` blocks in the `random/array/*` declaration files called the main function (e.g. `normal( 2.0, 5.0, x )`) instead of `normal.assign( 2.0, 5.0, x )`. The bare call throws at runtime because the main function's first argument must be a nonnegative integer (array length), so the example's `out === x` assertion never holds. Correct the example in all affected packages and fix the unary, binary, and ternary scaffold templates (which additionally passed `out` instead of `x` as the output array) to prevent regeneration of the error.
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
kgryte
approved these changes
Jun 10, 2026
Member
|
As the CI failure is not due to changes introduced in this PR, I'll go ahead and merge. |
assign examples in random/array TypeScript declarationsassign examples in random/array TypeScript declarations
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.
Description
This pull request fixes the
assignmethod@exampleblocks in the TypeScript declaration (index.d.ts) files across the@stdlib/random/arraynamespace.The examples called the main function with the output array as an argument (e.g.
normal( 2.0, 5.0, x )) rather than theassignmethod (normal.assign( 2.0, 5.0, x )). The bare call throws at runtime because the main function's first argument must be a nonnegative integer (the array length):As a result, the documented
var bool = ( out === x ); // returns trueassertion never holds. The fix:assignexample to call<name>.assign( ... )in 32random/array/*declaration files (arcsine,bernoulli,beta,betaprime,binomial,cauchy,chi,chisquare,cosine,discrete-uniform,erlang,exponential,f,frechet,gamma,gumbel,hypergeometric,invgamma,kumaraswamy,laplace,levy,logistic,lognormal,negative-binomial,normal,pareto-type1,poisson,rayleigh,t,triangular,uniform,weibull).unary,binary, andternaryscaffold templates underrandom/array/scripts/scaffolds, which generate these declarations. The templates additionally passedout(undefined) instead ofxas the output array; both issues are corrected to prevent regeneration of the error.Each corrected example was verified at runtime (
out === xis nowtrue). The READMEs already used the correct.assignform, so this brings the declarations into alignment with them. No types or signatures are modified.Related Issues
No.
Questions
No.
Other
Surfaced while reviewing #12571 (a TSDoc audit of the
randomnamespace).Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
The bug was surfaced and fixed using Claude Code. Each corrected example was verified at runtime against the actual implementation, and the changes were reviewed by myself before submitting.
@stdlib-js/reviewers