Skip to content
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

Compiler should throw an error if I use @HostListener in a service #363

Closed
mgechev opened this issue Jul 1, 2017 · 2 comments · Fixed by #370
Closed

Compiler should throw an error if I use @HostListener in a service #363

mgechev opened this issue Jul 1, 2017 · 2 comments · Fixed by #370
Assignees

Comments

@mgechev
Copy link
Owner

mgechev commented Jul 1, 2017

I'm submitting a ...

[ ] Regression (behavior that used to work and stopped working in a new release)
[ ] Bug report
[ X ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Current behavior

I'm allowed to put @HostListener in a service, even if it doesn't work

Expected behavior

The compiler should fail (or at least emit a warning?) telling me that the use of @HostListener within a service (or any other place that doesn't have a host) won't work.

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Just a quality-of-life improvement

By @adamdport
Source angular/angular#17847

@rafaelss95
Copy link
Collaborator

rafaelss95 commented Jul 1, 2017

@mgechev extending to this... the same happens if you implement/use ngOnInit in a service.

@wKoza
Copy link
Collaborator

wKoza commented Jul 2, 2017

At first, we can focus on decorators like @HostListener, @HostBinding, @Input, @Output, ... But it would be interesting to work on the life cycle in another rule.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants