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

Report Error when checking if two unboxed signals are > or < each other? #54986

Closed
skyleguy opened this issue Mar 21, 2024 · 2 comments
Closed

Comments

@skyleguy
Copy link

skyleguy commented Mar 21, 2024

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

core

Description

During a talk from Manfred during NgConf an issue happened multiple times that could definitely be hard to figure out. Essentially there were two signals:

sig1 = signal(5)
sig2 = signal(2)

The idea was then to compare the unboxed values of these two signals, but by accident they were left unboxed like so:

if (this.sig1 > this.sig2)

seemingly this condition would never return true since two signals would never be <, <=, >, >= each other (although could be === ?)

This seems like a very easy mistake to make, especially since signals are so new. of course simply unboxing the two signals allows the correct logic to happen but it seems like any dev regardless of experience could take some time to figure out why their logic is not working correctly due to this.

Would it be possible to get error output for this similar to what happens when trying to compare two types that shouldnt be compared (like string and int)

Screenshot 2024-03-21 at 4 25 27 PM

Proposed solution

would be amazing to get some sort of similar error prompt that states something along the lines of:

"Operator '>' cannot be applied to types 'Signal' and 'Signal'"

Alternatives considered

Possibly we could also get an error similar to what happens in the template when we do @if(sig1) instead of @if(sig1()) that looks like This condition will always return false since signals cannot be compared in this way. Did you mean to call them instead?

@JeanMeche
Copy link
Member

Hi, you should open a feature request on angular-eslint/angular-eslint.
This is in the scope of a linting rule.

@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 Apr 23, 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