Skip to content

feat(core): Provide a diagnostic for missing Signal invocation in template interpolation.#49660

Closed
JeanMeche wants to merge 4 commits intoangular:mainfrom
JeanMeche:feat/signal-call-templatecheck
Closed

feat(core): Provide a diagnostic for missing Signal invocation in template interpolation.#49660
JeanMeche wants to merge 4 commits intoangular:mainfrom
JeanMeche:feat/signal-call-templatecheck

Conversation

@JeanMeche
Copy link
Member

To improve DX for beginners, this commit ads an extended diagnostic for Signals in template interpolations.

See #49657

PR Type

What kind of change does this PR introduce?

  • Feature

Does this PR introduce a breaking change?

  • No

@angular-robot angular-robot bot added the detected: feature PR contains a feature commit label Mar 31, 2023
@JeanMeche JeanMeche force-pushed the feat/signal-call-templatecheck branch 2 times, most recently from a40e89f to e88232a Compare March 31, 2023 17:10
@dylhunn
Copy link
Contributor

dylhunn commented Mar 31, 2023

This sounds like a great idea for a template diagnostic! Looking forward to it being ready for review/discussion!

@dylhunn dylhunn added area: compiler Issues related to `ngc`, Angular's template compiler compiler: extended diagnostics labels Mar 31, 2023
@ngbot ngbot bot modified the milestone: Backlog Mar 31, 2023
@dylhunn dylhunn added the target: major This PR is targeted for the next major release label Mar 31, 2023
@JeanMeche JeanMeche force-pushed the feat/signal-call-templatecheck branch 3 times, most recently from b9572fd to 9fe1153 Compare April 1, 2023 23:50
@JeanMeche JeanMeche force-pushed the feat/signal-call-templatecheck branch from 9fe1153 to 4e19b00 Compare April 2, 2023 11:04
@JeanMeche JeanMeche marked this pull request as ready for review April 2, 2023 11:22
@pullapprove pullapprove bot requested a review from AndrewKushnir April 2, 2023 11:22
@AndrewKushnir AndrewKushnir requested review from dylhunn and removed request for AndrewKushnir April 3, 2023 03:54
@pullapprove pullapprove bot requested a review from AndrewKushnir April 3, 2023 03:55
@JeanMeche JeanMeche force-pushed the feat/signal-call-templatecheck branch from 4e19b00 to b0bd5c4 Compare April 4, 2023 13:48
@dylhunn dylhunn self-requested a review April 4, 2023 18:50
@dylhunn
Copy link
Contributor

dylhunn commented Apr 4, 2023

@JeanMeche Since this visits every node in the AST, what about expressions like fn(signalA)? It seems like this diagnostic will still fire. But you might sometimes want to actually pass the signal, as opposed to just reading it?

@JeanMeche
Copy link
Member Author

@dylhunn This is already covered, I'll add a test though !

@JeanMeche JeanMeche force-pushed the feat/signal-call-templatecheck branch from b0bd5c4 to 6784cd8 Compare April 4, 2023 19:59
@dylhunn
Copy link
Contributor

dylhunn commented Apr 5, 2023

@crisbeto Highlighted some potential concerns before we merge this. Let's target v16.1.

  1. It only checks interpolations, not things like [attr.foo]="signal"
  2. It doesn’t check host bindings because extended diagnostics don’t have access to them.
  3. Would be better to fin a cleaner way to detect a Signal

@JeanMeche JeanMeche modified the milestones: Backlog, v17 candidates Aug 5, 2023
@pullapprove pullapprove bot requested a review from alxhub August 5, 2023 20:56
@devversion
Copy link
Member

devversion commented Oct 10, 2023

The regular binding (ex.: <div [myDirectiveInput]="sig"> is tricker as there are legitimate cases where someone might want to pass a reference to a signal (instead of unwrapping its value).

Just to capture this here: And in those cases, the normal type-checking is already sufficient and will complain if e.g. myDirectiveInput does not take a Signal<T>

@JeanMeche JeanMeche force-pushed the feat/signal-call-templatecheck branch from 792cccc to 3286016 Compare October 10, 2023 11:56
@dylhunn
Copy link
Contributor

dylhunn commented Oct 10, 2023

@pkozlowski-opensource @JeanMeche Just to confirm, the regular non-interpolated binding case <div [myDirectiveInput]="sig"> Pawel describes does not produce a diagnostic, right?

Edit: saw the slack thread, thanks!

@JeanMeche
Copy link
Member Author

the regular non-interpolated binding case <div [myDirectiveInput]="sig"> Pawel describes does not produce a diagnostic, right?

No, it won't produce a diagnostic. The typechecker should do that.

Copy link
Contributor

@dylhunn dylhunn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For pullapprove:

reviewed-for: fw-compiler, public-api

@dylhunn dylhunn added action: merge The PR is ready for merge by the caretaker merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note labels Oct 10, 2023
@dylhunn
Copy link
Contributor

dylhunn commented Oct 10, 2023

Caretaker: windows is a flake. PR has sufficient approvals (me and Pawel).

@angular-robot
Copy link
Contributor

angular-robot bot commented Oct 10, 2023

This PR was merged into the repository by commit 8eef694.

@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 Nov 11, 2023
ChellappanRajan pushed a commit to ChellappanRajan/angular that referenced this pull request Jan 23, 2024
…plate interpolation. (angular#49660)

To improve DX for beginners, this commit adds an extended diagnostic for Signals in template interpolations.

PR Close angular#49660
@JeanMeche JeanMeche deleted the feat/signal-call-templatecheck branch February 29, 2024 13:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: compiler Issues related to `ngc`, Angular's template compiler compiler: extended diagnostics detected: feature PR contains a feature commit merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note PullApprove: disable target: major This PR is targeted for the next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants