fix(language-service): properly evaluate types in comparable expressions (#36529)

This commit fixes how the language service evaluates the compatibility
of types to work with arbitrary union types. As a result, compatibility
checks are now more strict and can catch similarities or differences
more clearly.

```
number|string == string|null  // OK
number|string == number       // OK
number|string == null         // not comparable
number == string              // not comparable
```

Using Ivy as a backend should provide these diagnoses for free, but we
can backfill them for now.

Closes https://github.com/angular/vscode-ng-language-service/issues/723

PR Close #36529
This commit is contained in:
Ayaz Hafiz
2020-04-08 13:48:35 -07:00
committed by Matias Niemelä
parent 78840e59a7
commit 8be0972836
6 changed files with 69 additions and 81 deletions

View File

@ -133,4 +133,5 @@ export class TemplateReference {
readonlyHeroes: ReadonlyArray<Readonly<Hero>> = this.heroes;
constNames = [{name: 'name'}] as const;
private myField = 'My Field';
strOrNumber: string|number = '';
}