Closed Phryxia closed 8 months ago
For my suggestion, how about this? I think people use T often to express generic type for input. R means return, but if you have better ideas, please go with them.
I didn't know there was such a rule or convention in TypeScript. I like the method you suggested.
I think It's good to explain case of accumulator differ to value. I think it's pretty common in real life. Like adding following in the jsdoc of reduce.
Also, I think it would be a good idea to add the explanation you wrote above.
If it's okay with you, could you please create a PR??
I didn't know there was such a rule or convention in TypeScript.
Oh there is no such explicit rule! But as my experience, many types of other libraries or example code seem to use T for such purpose. (Maybe because it stands for Type) R was just my private opinion :p
I'll raise a PR soon so let's enhance them :)
Suggestion
⭐ Suggestion
Bad parameter name or generic name
In the jsdoc of
reduce
, variable name is really confusing since it's justa
andb
. It's different to simple binary operation (likeadd
ormul
). After I inspect type signature, it's getting worse because of(a: B, b: A) => B
.In tslib, they used following for
Array.prototype.reduce
.In #MDN reference, they use following description.
For my suggestion, how about this? I think people use
T
often to express generic type for input.R
means return, but if you have better ideas, please go with them.Requires more elaboration for docs of
reduce
I think It's good to explain case of accumulator differ to value. I think it's pretty common in real life. Like adding following in the jsdoc of
reduce
.Also always thanks for great library, it helps me a lot.
💻 Use Cases
More developers can understand the powerful features of
reduce
.