-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pipe does not properly support rest parameters in some cases. #4177
Comments
My memory's not clear, but didn't we replace those signature into else for some reason? 872b0ec#diff-eeb9d77f742ad0df7e932697062fc44e /cc @cartant |
@kwonoj ... I think the issue is that TypeScript is not honoring line 321 there. It needs to be added to the signature. |
Regarding spreading, see #3989 |
Yup, I see the issue now. Adding a proposed change to the OP. |
…rators directly resolves ReactiveX#4177
I'm probably missing something obvious, but over the weekend I had a play around with making the args to all the Observable pipe overloads optional, and as far as I could see that had the effect of restoring pipe spread arg typing that is at least as good as it was pre v6.3 (and not causing a regression on #3841 ) All the dtslint tests seemed to pass, and this wouldn't require special-casing an array argument to pipe, so for eg I believe that Angular So it would look like
I didn't have time to turn this into a PR, and I didn't really test properly under TS 2.8 (only 3.0), but I got as far as making these notes:
|
IMO, adding an array overload signature would be the preferred solution. It's simple and easy to understand and will effect errors for And TypeScript 3.0 supports using the spread syntax in a fully type-safe manner. So eventually this will be a non-issue. |
Also, I'm not entirely sure why making them optional should effect such different behaviour. It's interesting, but I'd have some concerns that the behaviour could change. Especially, if the reason for it isn't easily explained. |
Maybe X.pipe(
...some_adapters,
an_adapter(),
...some_more_adapters,
) should be currently solved by X.pipe(
pipeFromArray(some_adapters),
an_adapter(),
pipeFromArray(some_more_adapters),
) ? |
* type reason: pipe operator with more than 9 operations lose type. (ReactiveX/rxjs#4177) * coronaCheckEpic receives POJO, ans returns observable hence is a callback passed to operator, rather than an operator itself.
Bumping this. I would at least like an overload that supports an array of single type operators: pipe<T extends UnaryFunction<any, any>>(...fns: Array<T>): T and the same for |
I encountered this while updating Angular CLI.
In particular, the update to the
base.ts
file in there, where I'm addingas any
was necessary because the spreading of an array of operators intopipe
was not working.EDIT: It seems that we can't support rest params without breaking inference enforcement from operator to operator in the pipe. So here's a proposal:
Proposed Feature
Add an overload of
pipe
that acceptsOperatorFunction<any, any>[]
and returnsObservable<R>
:The text was updated successfully, but these errors were encountered: