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.

Idea: replace length-specific overloads with TS 4.0 variadic tuple types

See original GitHub issue

TypeScript 4.0 added variadic tuple types.

Mammoth’s variable-length methods like .select(...) are currently implemented with one signature overload for each length of arguments, from 1-75. Can/should that be replaced with variadic tuple types?

Potential advantages:

  1. My IDE occasionally freezes for ~3 seconds when trying to show the autocomplete for methods like .select(...). I wonder if that’s because of the number of length-specific overloads.
  2. I wonder if things like this will be easier: https://github.com/Ff00ff/mammoth/issues/218. (I don’t actually know…)
  3. Potentially better type error messages.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
martijndehcommented, Jul 24, 2021

Thanks, this is fixed now. I’ll try to apply this technique to the other many signature overloads like returning().

0reactions
cakoosecommented, Jul 18, 2021

Go for it! (If I get another chance to look at this, I’ll update this issue.)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation - TypeScript 4.0
Variadic Tuple Types. Consider a function in JavaScript called concat that takes two array or tuple types and concatenates them together to make...
Read more >
TS 4.0 Variadic tuple types: type inference with optional ...
TS 4.0 Variadic tuple types : type inference with optional element not ... Use overloads to get the desired effect of an optional...
Read more >
TypeScript 4.0 Adds Long-Awaited Variadic Tuple Types - InfoQ
The first change is that spreads in tuple type syntax can now be generic. This means that we can represent higher-order operations on...
Read more >
Variadic Tuple Types: example from the docs - Stack Overflow
My question is: why in the older versions of the language we would need to use so many overloads? Are there no better...
Read more >
Experimenting with TypeScript 4.0's Variadic Tuple Types ...
I wrote some code over 2 years ago that couldn't be properly typed with either Flow or TypeScript, but with the introduction of...
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