3 ms·
I agree, that doesn't look bad. However, this type definition forces you to supply one argument per function call, which looks awful in JavaScript: fn(1)(2
by tommikaikkonen 9y ago
I agree, that doesn't look bad. However, this type definition forces you to supply one argument per function call, which looks awful in JavaScript:
fn(1)(2)(3)
That's a big drawback for me. Libraries like Ramda allow one or more arguments per function call:
fn(1, 2, 3) === fn(1, 2)(3) === fn(1)(2, 3)
That's what makes the verbosity unbearable, as each type of call needs its own type.
- noppa 9y agoAt least in Flow it's actually possible to properly type curried functions! Here's a gist of the type definitions I'm using: https://gist.github.com/noppa/c600cc43fd44e33768efe6c6eec4a99a https://gist.github.com/noppa/c600cc43fd44e33768efe6c6eec4a9... I think something similar might work in TS too. Demo: https://goo.gl/w3aPsw https://goo.gl/w3aPsw