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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug(core): EventEmitter#subscribe() should be properly typed #29016
Comments
What about this workaround this.weatherChange.asObservable().subscribe(weather => {}); mouse over weather is https://stackblitz.com/edit/angular-issues-29016?file=src%2Fapp%2Fmy%2Fmy.component.ts |
@william-lohan thanks! That's good enough for me. |
I still think this should be typed correctly right away, so I would vote to not close this. |
@Airblader ok, I'll leave open for now. |
I made a simple implementation based on overloads to follow the current implementation. If you want, I can make a PR with this In the Playground all three are showed, but with the overload, only the first two will, and also will allow to discriminate between the calls. |
When passed an observer object, the next callback had any as argument, this commit improve this behavior. Fixes: angular#29016
When passed an observer object, the next callback had any as argument, this commit improve this behavior. Fixes: angular#29016
When passed an observer object, the next callback had any as argument, this commit improve this behavior. Fixes: angular#29016
When passed an observer object, the next callback had any as argument, this commit improve this behavior. Fixes: angular#29016
馃殌 feature request
Relevant Package
This feature request is for @angular/coreDescription
Currently, subscribing to an
EventEmitter
(viaEventEmitter#subscribe()
) stripes the EventEmitter's type information and converts it toany
. This is undesirable, as already pointed out in #6934.That issue was closed with a nondescript explanation that ~ "you shouldn't use the EventEmitter's
subscribe()
method". However,EventEmitter#subscribe()
is not marked as internal API.The suggestion that someone should create a duplicate property, using an rxjs subject, solely for the purpose of improved typing, is unsatisfactory.
This is a request to do whatever needs to be done to allow subscribing to
EventEmitter
directly while preserving type information.Describe the solution you'd like
The type information, which is already present on
EventEmitter
, should be retained.Describe alternatives you've considered
Currently, the suggested workaround seems to be to create a duplicate property and update both the
@Output()
property and the duplicateSubject
property whenever the associated data changes.e.g.
The text was updated successfully, but these errors were encountered: