angular/packages/compiler-cli
Doug Parker 263feba5c2 fix(compiler-cli): handle nullable expressions correctly in the nullish coalescing extended template diagnostic (#43572)
Refs #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)`](fe69193509/packages/compiler-cli/src/ngtsc/typecheck/extended/checks/nullish_coalescing_not_nullable/index.ts (L30)) would return the [symbol of the function (`foo`)](fe69193509/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.

PR Close #43572
2021-10-04 17:32:57 -07:00
..
integrationtest test(compiler-cli): fix integration test failing on windows due to missing runfile symlinking (#43431) 2021-10-01 18:28:46 +00:00
linker refactor(compiler-cli): no longer use deep imports into @angular/compiler (#43431) 2021-10-01 18:28:46 +00:00
ngcc refactor(compiler-cli): remove dependency on minimist (#43644) 2021-10-04 17:31:03 -07:00
private refactor(compiler-cli): expose tooling code through private entry-point (#43431) 2021-10-01 18:28:46 +00:00
src fix(compiler-cli): handle nullable expressions correctly in the nullish coalescing extended template diagnostic (#43572) 2021-10-04 17:32:57 -07:00
test refactor(compiler-cli): remove dependency on minimist (#43644) 2021-10-04 17:31:03 -07:00
BUILD.bazel refactor(compiler-cli): remove dependency on minimist (#43644) 2021-10-04 17:31:03 -07:00
esbuild.config.js refactor: setup bundling for @angular/compiler-cli package (#43431) 2021-10-01 18:28:42 +00:00
import_meta_url.d.ts refactor(compiler-cli): do not use __filename or __dirname global for ESM compatibility (#43431) 2021-10-01 18:28:45 +00:00
index.ts refactor(compiler-cli): expose tooling code through private entry-point (#43431) 2021-10-01 18:28:46 +00:00
package.json refactor(compiler-cli): remove source-map from dependencies (#43644) 2021-10-04 17:31:03 -07:00
tsconfig-build.json build: update tsconfigs to use ES2020 as target and module (#43431) 2021-10-01 18:28:42 +00:00
tsconfig.json build: update tsconfigs to use ES2020 as target and module (#43431) 2021-10-01 18:28:42 +00:00