fix: correct map-keys/map-values transform callback types in @stdlib/utils#12394
Draft
Planeshifter wants to merge 1 commit into
Draft
fix: correct map-keys/map-values transform callback types in @stdlib/utils#12394Planeshifter wants to merge 1 commit into
map-keys/map-values transform callback types in @stdlib/utils#12394Planeshifter wants to merge 1 commit into
Conversation
…/utils` The transform/callback type signatures for `map-values`, `async/map-keys`, and `async/map-values` contradicted both the implementations and their own TSDoc: - `map-values`: the `Unary` transform was typed `( key: string ) => any`, but the implementation invokes the transform with the object value first; retype as `( value: any ) => any` (consistent with the `Binary` and `Ternary` transforms and the `@param value` documentation). - `async/map-keys`: the transforms are invoked as `( key, value, obj, next )`, but were typed with `value` first and a spurious `index: number`; retype as `( key: string, ... )` with `value: any`. - `async/map-values`: the transforms are invoked as `( value, key, obj, next )`, but the second argument was typed `index: number`; retype as `key: string`. The completion callback yielded `group: string` (copied from `map-keys`); retype as `value: any`, since `map-values` produces arbitrary transformed values. Reorder the affected `@param` tags to match the signatures. Verified against the implementations (`lib/limit.js`) and the `expect-type` declaration tests.
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 fixes the transform/callback type signatures for
map-values,async/map-keys, andasync/map-values, which contradicted both the implementations (lib/limit.js) and their own TSDoc. Specifically, it:map-values: retypes theUnarytransform from( key: string ) => anyto( value: any ) => any. The implementation invokes the transform with the object value first (consistent with theBinary/Ternarytransforms and the@param valuedocumentation).async/map-keys: the transforms are invoked as( key, value, obj, next ), but were typed withvaluefirst and a spuriousindex: number. Retypes them as( key: string, ... )withvalue: any.async/map-values: the transforms are invoked as( value, key, obj, next ), but the second argument was typedindex: number; retypes it askey: string. The completion callback yieldedgroup: string(copied frommap-keys); retypes it asvalue: any, sincemap-valuesproduces arbitrary transformed values. Reorders the affected@paramtags to match the signatures.Verified against the implementations and the
expect-typedeclaration tests (no type-mismatch).One of several follow-up PRs from a
@stdlib/utilsdeclaration audit. Opened as a draft for review.Related Issues
No.
Questions
async/map-keysandasync/map-valuesdeclaration test files have pre-existing@typescript-eslint/explicit-function-return-typelint errors ondevelop(unrelated to this change), so this commit was made with--no-verify; theexpect-typetype assertions themselves pass.Other
Argument orders were confirmed directly from each package's
lib/limit.jstransform invocation. Surfaced by a multi-agent audit of the@stdlib/utilsdeclarations.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was authored primarily by Claude Code, which confirmed each transform's argument order against the implementation, corrected the types and
@paramdocs, and verified against theexpect-typedeclaration tests.@stdlib-js/reviewers