-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Closed as not planned
Closed as not planned
Copy link
Labels
SuggestionAn idea for TypeScriptAn idea for TypeScriptToo ComplexAn issue which adding support for may be too complex for the value it addsAn issue which adding support for may be too complex for the value it adds
Description
Search Terms
variadic pipe rxjs
Suggestion
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.
Maybe some sort of syntax like:
declare type OperatorFunction<T, R> = (source: Observable<T>) => Observable<R>;
class Observable<T> {
pipe<R, U extends [OperatorFunction<T, any>, ...OperatorFunction<any, any>[], OperatorFunction<any, R>]>(...operators: U): Observable<R>;
}It's a tricky case because type inferance also has to work.
Use Cases
RxJS currently has a lot of overloads just to support what is really a common functional programming feat.
Examples
Mostly I'd use this as shown above to define the pipe method on Observable.
Really I'm looking for any solution to this problem though. It's a very common complaint from our TypeScript users.
🙏
Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript / JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. new expression-level syntax)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
SuggestionAn idea for TypeScriptAn idea for TypeScriptToo ComplexAn issue which adding support for may be too complex for the value it addsAn issue which adding support for may be too complex for the value it adds