-
Notifications
You must be signed in to change notification settings - Fork 3k
Operator functions are acceptable to concat() function in Typescript. #4563
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
Comments
The signatures you have included in your issue are for the (deprecated) operator, but you appear to be using the observable creator in your snippets. |
I found the signatures from the code of observable creator, which was modified in this commit I'll update the issue with new type signatures. Sorry for confusing. |
This issue is no longer a real problem, as newer versions of RxJS and TypeScript will not allow this. However, I've started a new issue #6011, because |
Closing because of #4563 (comment) |
Also, this should be resolved when I get around to replacing the |
Bug Report
Current Behavior
rxjs is not able to subscribe general functions like
() => {}
. So, the following code must make errors.Of course, It makes an error on 3rd line, but if we add a slight of type hints, it makes things confuse.
Now there's no error!
Every functions are instance of
ArrayLike<any>
and where ArrayLike is defined asIt doesn't matter, if we don't add an explicit type hint for being a function to ArrayLike.
But there are some problem originated from this issue.
Reproduction
I meant to write codes like following
But, by mistake, I actually wrote the code like
But it still compiled without any type errors!
I didn't notice my mistake, and tried to subscribe an observable from the factory function, and it showed an errors at runtime.
It happened since
concat()
has following type signatureThe return type of catch error is
OperatorFunction<T, T | R>
and it is converted like following.Expected behavior
It have to make errors before 5th line.
Environment
I spent a lot of time to debug my problem. It would be helpful to the people who are suffering the problem like mine.
The text was updated successfully, but these errors were encountered: