Microsoft/TypeScript

Array<T>.reduce<U> method description contains mismatched parameter in description

Open

#55,077 建立於 2023年7月19日

在 GitHub 查看
 (2 留言) (0 反應) (0 負責人)TypeScript (6,726 fork)batch import
BugDomain: lib.d.tsHelp Wanted

倉庫指標

Star
 (48,455 star)
PR 合併指標
 (平均合併 6天 17小時) (30 天內合併 9 個 PR)

描述

Bug Report

file node_modules/typescript/lib/lib.es5.d.ts, lines 1386, 1392, 1393, 1399. ParameterpreviousValue of the callbackfn in reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T) method is named accumulator in the JSDoc, instead of previousValue, potentially causing confusion when reading the documentation provided.

🔎 Search Terms

Array<T>.reduce<U>, Array<T>.reduce<U>(callbackfn:(previousValue, accumulator

🕗 Version & Regression Information

  • typescript version 4.4.4

⏯ Playground Link

Playground link with relevant code

💻 Code

// Welcome to the TypeScript Playground, this is a website
// which gives you a chance to write, share and learn TypeScript.

// You could think of it in three ways:
//
//  - A location to learn TypeScript where nothing can break
//  - A place to experiment with TypeScript syntax, and share the URLs with others
//  - A sandbox to experiment with different compiler features of TypeScript

const anExampleVariable = "Hello World"
console.log(anExampleVariable)

const arr = ['foo', 'bar', 'baz', 'acc'];

const reduceArr = arr.reduce((prev, curr) => {return prev.concat(curr);});

// To learn more about the language, click above in "Examples" or "What's New".
// Otherwise, get started by removing these comments and the world is your playground.

🙁 Actual behavior

previousValue parameter of callbackfn is named accumulator in JSDoc

🙂 Expected behavior

Either previousValue parameter of callbackfn should be named previousValue in JSDoc, or the parameter of callbackfn should be renamed to accumulator, in order to avoid confusion.

貢獻者指南