question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

applyEach arguments position

See original GitHub issue

Currently the applyEach and applyEachSeries functions have the following type signature:

async.applyEach(fns, ...args?, callback?)

Having a rest parameter in the middle of the arguments list is very difficult to write a type annotation for. It’s currently not possible in either Flow or TypeScript, which is why you see stuff like this (I’m writing a similar type definition for Flow right now).

Would it be okay to switch the argument order around and make callback nullable so it is like this?

async.applyEach(fns, callback | null, ...args?)

Or use an array instead of a rest parameter?

async.applyEach(fns, args?: Array<any>, callback?)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:18

github_iconTop GitHub Comments

1reaction
jamiebuildscommented, Jul 12, 2016

I’ve proposed allowing the usage of spread elements within tuples to solve this case syntactically

function method(...args: [string, ...number, boolean]) {}
1reaction
aearlycommented, Jul 12, 2016

BTW, I’m 👍 for having the args be an array in the case of applyEach. Having an optional param after a rest param will always lead to ambiguities.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use contents of a list as positional arguments to a single ...
It is possible to represent N-ary functions like so: data FunN r a = FunN Int (a -> FunN r a) | FNil...
Read more >
Accepting any number of arguments to a function
To make a function that accepts any number of arguments, you can use the * operator and then some variable name when defining...
Read more >
On Philosophical Argumentation
Johnstone is correct, who, analyzing the ideas of "cogency" and "formai validity," emphasizes that "cogent philosophical arguments are formally valid, and no ...
Read more >
Function.prototype.apply() - JavaScript - MDN Web Docs
The apply() method calls the specified function with a given this value, and arguments provided as an array (or an array-like object).
Read more >
Python: module Gui
keyword arguments are passed as options to the widget constructor. ... pos(bbox, offset): return the position at the given offset from bbox upper-left....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found