You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Improve rest Generics in 3.0 RC sufficiently to support RxJS Observable.prototype.pipe #25660
Improve variadic kind support to allow determining the final part of the kind in some way. The problem is currently in 3.0-rc, I haven't found a way to improve RxJS's pipe method. There are a lot of people using TypeScript with RxJS and this has been a pain point for all of them.
#24897 didn't claim to solve everything in #5453, and I don't think we're expecting any new changes in 3.0, but we'll be continuing to think about solutions for variadic types.
That doesn't mean this problem won't get solved in another 3.x release though, so hopefully you don't think you're running out of time or anything like that.
sirian You're kidding! That's great. I think we just all assumed that that would be too good to be true, and never thought to try it. https://github.com/pelotom/type-zoo is the repo I was talking about if you want to join in ;)
BTW, at 2.9 I used trick with inversed check of function signatures (((...) => any) extends F instead of F extends (...) => any). Maybe this information would be helpful
Ben Lesh (@benlesh) Much as I share your distaste for walls of overloads, this actually seems like a case where it is merited. The manner in which types flow from the output of one argument to the input of the next would be really hard to capture in a single higher-order construct (and, to be sure, there are just so many different ways the types might flow that elevating a single pattern to a new construct seems questionable).
Beyond the issue of only handling a fixed maximum number of arguments, what are the issues caused by the overload pattern? I'm curious about the specific pain point you refer to.
I'm not sure you want to close this as someone else is likely to report it. May be add the topic somewhere else with an explainer about why it can't be done? Then close? Not my repo. Not my call.
Activity
benlesh commentedon Jul 14, 2018
Related: #5453
DanielRosenwasser commentedon Jul 14, 2018
#24897 didn't claim to solve everything in #5453, and I don't think we're expecting any new changes in 3.0, but we'll be continuing to think about solutions for variadic types.
That doesn't mean this problem won't get solved in another 3.x release though, so hopefully you don't think you're running out of time or anything like that.
fbartho commentedon Jul 14, 2018
Ben Lesh (@benlesh) I just added this to type-zoo:
https://github.com/pelotom/type-zoo/blob/master/types/index.d.ts#L66-L77
I don't know how to do this in a variadic way to work for the pipe function, but you could manually type it for up to N-piped helpers.
For your use case, obviously, infer the whole type, and extract the
ReturnType, and somehow chain them together.Thoughts?
sirian commentedon Jul 16, 2018
Frederic Barthelemy (@fbartho)
seems like this working:
tests:
fbartho commentedon Jul 16, 2018
sirian You're kidding! That's great. I think we just all assumed that that would be too good to be true, and never thought to try it. https://github.com/pelotom/type-zoo is the repo I was talking about if you want to join in ;)
sirian commentedon Jul 16, 2018
Frederic Barthelemy (@fbartho) ArgCount also is pretty simple
BTW, at 2.9 I used trick with inversed check of function signatures (
((...) => any) extends Finstead ofF extends (...) => any). Maybe this information would be helpfulahejlsberg commentedon Jul 16, 2018
Ben Lesh (@benlesh) Much as I share your distaste for walls of overloads, this actually seems like a case where it is merited. The manner in which types flow from the output of one argument to the input of the next would be really hard to capture in a single higher-order construct (and, to be sure, there are just so many different ways the types might flow that elevating a single pattern to a new construct seems questionable).
Beyond the issue of only handling a fixed maximum number of arguments, what are the issues caused by the overload pattern? I'm curious about the specific pain point you refer to.
benlesh commentedon Aug 27, 2018
Mostly it's a fixed maximum number of arguments... after that, the typings get manual and squishy and I get complaints.
If we ever get a pipeline operator, this problem effectively goes away.
benlesh commentedon Aug 27, 2018
Daniel Rosenwasser (@DanielRosenwasser) Anders Hejlsberg (@ahejlsberg) ... I'm not sure whether to keep this open or close it. On one hand, it's an issue that people are going to hit. On the other hand, nothing is going to be done about it.
🤷♂️
Leave open, mark "won't fix"?
steve-taylor commentedon Aug 22, 2020
Does TypeScript 4’s variadic tuple types help solve this issue? I’m struggling to get my head around it, so I genuinely don’t know the answer.
benlesh commentedon Aug 26, 2020
Steve Taylor (@steve-taylor) this particular issue with pipe, no. It solves loads of other issues, but this core issue is still a problem.
steve-taylor commentedon Aug 26, 2020
See proposal in #30370.
typescript-bot commentedon Jun 21, 2023
This issue has been marked as "Too Complex" and has seen no recent activity. It has been automatically closed for house-keeping purposes.
benlesh commentedon Jun 21, 2023
I'm not sure you want to close this as someone else is likely to report it. May be add the topic somewhere else with an explainer about why it can't be done? Then close? Not my repo. Not my call.