fix: correct return type of the options-only factory overload in random/streams/triangular#12565
Draft
Planeshifter wants to merge 1 commit into
Draft
Conversation
…ndom/streams/triangular The function returned by the options-only `factory` overload creates streams generating pseudorandom numbers drawn from a triangular distribution, which is parameterized by the minimum support `a`, the maximum support `b`, and the mode `c`. The returned function thus accepts three arguments, but the declared type listed only `a` and `b`. Correct the return type to `( a: number, b: number, c: number ) => RandomStream` to match the implementation and the documented example, and align the corresponding type test.
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
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:
factoryoverload inrandom/streams/triangular.The function returned by the options-only
RandomStream.factory( options? )overload creates streams generating pseudorandom numbers drawn from a triangular distribution, which is parameterized by the minimum supporta, the maximum supportb, and the modec. The returned function therefore accepts three arguments, but the declared type listed onlyaandb:This matches the implementation (
lib/main.js/lib/factory.js, whose returned creator takes( a, b, c )) and the overload's own documented@example, which callscreateStream( 2.0, 5.0, 4.0 ). The corresponding$ExpectTypeassertion intest.tsis aligned to use three arguments.The existing type test continued to pass against the buggy type only because, in the positive-assertion block, the test variable is first assigned from the four-argument
factory( a, b, c, options )overload (whose return type is( ...args: Array<any> ) => RandomStream), masking the arity of the options-only overload.Related Issues
No.
Questions
No.
Other
This change was identified during a TypeScript-declaration audit of the
@stdlib/randomnamespace.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
A TypeScript-declaration audit surfaced this issue using Claude Code; the finding was independently verified against the implementation, and the proposed change was reviewed by myself before submitting.
@stdlib-js/reviewers