Idea: replace length-specific overloads with TS 4.0 variadic tuple types
See original GitHub issueTypeScript 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:
- 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. - I wonder if things like this will be easier: https://github.com/Ff00ff/mammoth/issues/218. (I don’t actually know…)
- Potentially better type error messages.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks, this is fixed now. I’ll try to apply this technique to the other many signature overloads like
returning()
.Go for it! (If I get another chance to look at this, I’ll update this issue.)