Repository navigation
Conversation
387275a to
b9bd2f9
Compare
b687ada to
f13cd2d
Compare
f13cd2d to
89035bf
Compare
89035bf to
689ad58
Compare
…sh coalescing extended template diagnostic Refs angular#42966. Previously, checking a template with the syntax: ```html <div>{{ foo() ?? 'test' }}</div> ``` Where `foo()` returns a nullable value: ```typescript @component(/* ... */) class TestCmp { foo: (): string | null => null; } ``` Would always log a nullish coalescing not nullable warning. This is because [`getSymbolOfNode(node.left)`](https://github.com/angular/angular/blob/fe691935091aaf7090864c8111a15f7cc7e53b6c/packages/compiler-cli/src/ngtsc/typecheck/extended/checks/nullish_coalescing_not_nullable/index.ts#L30) would return the [symbol of the function (`foo`)](https://github.com/angular/angular/blob/fe691935091aaf7090864c8111a15f7cc7e53b6c/packages/compiler-cli/src/ngtsc/typecheck/src/template_symbol_builder.ts#L536-L538) rather than the symbol of its returned value (`foo()`). Fixed this by getting the symbol for the whole expression's span, rather than just the function receiver. Also made some minor refactorings to `template_symbol_builder` to make a similar change to safe method calls. This behavior was originally for the language service in order to handle quick info, as the user highlighting a function name would actually apply to the entire expression. This is no longer true as the language service will correctly request the type from the function rather than the `Call` expression, so these hacks are not necessary anymore. This broke two existing test cases of exactly this behavior which were easily updated. Also added a test to the language service to confirm that it is not broken by this change.
689ad58 to
7006856
Compare
|
This PR doesn't merge cleanly into 12.2.x. Mind rebasing, or targeting major? |
|
@dylhunn, sorry about that. It looks like the previous PR (#38844) which introduced some of this code was not merged to I think we can just merge this to |
|
This PR was merged into the repository by commit 263feba. |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Checking a template with the syntax:
Where
foo()returns a nullable value:Will always log a nullish coalescing not nullable warning. This is because
getSymbolOfNode(node.left)would return the symbol of the function (foo) rather than the symbol of its returned value (foo()). Fixed this getting the symbol for the whole expression's span, rather than just the function receiver.This broke one existing test case of exactly this behavior which was easily updated. However, there's no explicit justification for why this test case was important. Nothing else seems to be obviously broken by this change.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: b/199443160
Getting the symbol of a
Callexpression returns the receiver's symbol rather than the value returned by the function call.What is the new behavior?
Getting the symbol of a
Callexpression now returns the symbol of the value returned by the function call. In particular, this fixes the nullish coalescing not nullable check to work correctly withCallexpression inputs.Does this PR introduce a breaking change?