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

As a developer I want to be warned when I mistakenly use a Signal in a template without calling it #55187

Closed
magwo opened this issue Apr 3, 2024 · 3 comments

Comments

@magwo
Copy link

magwo commented Apr 3, 2024

Which @angular/* package(s) are relevant/related to the feature request?

compiler, core

Description

A common mistake when using signals in templates, is to forget about calling the signal to get its value.

We already have protection against this in template interpolations. But we need the same kind of protection in regular bindings, for example:

[attr.data-e2e]="mySignal"

or

<my-component [someInput]="'someString' + mySignal">I forgot to add parentheses</my-component>

Proposed solution

I'm not very familiar with Angular internals but this seems like something that could be an "Extended diagnostic", like the template interpolation one?

Alternatives considered

Lint rules? I don't really know what would make sense.

@JeanMeche
Copy link
Member

Hi, this has been discussed when implementing the extended diagnostic for non-invoked signals.
There are legitimate cases where signals are not invoked (for example when there is an underlying model()).
Please have a look at #49657

@JeanMeche JeanMeche closed this as not planned Won't fix, can't repro, duplicate, stale Apr 3, 2024
@magwo
Copy link
Author

magwo commented Apr 3, 2024

Ok, understood! Maybe linting can be of help, eventually. I think my company, as an organization, currently would prefer to be warned about this, until we frequently start using Signals objects without calling them. We currently don't.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators May 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants