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:

committed by
Matias Niemelä

parent
78840e59a7
commit
8be0972836
@ -192,42 +192,47 @@ export enum BuiltinType {
|
||||
/**
|
||||
* The type is a type that can hold any other type.
|
||||
*/
|
||||
Any,
|
||||
Any = -1, // equivalent to b11..11 = String | Union | ...
|
||||
|
||||
/** Unknown types are functionally identical to any. */
|
||||
Unknown = -1,
|
||||
|
||||
/**
|
||||
* The type of a string literal.
|
||||
*/
|
||||
String,
|
||||
String = 1 << 0,
|
||||
|
||||
/**
|
||||
* The type of a numeric literal.
|
||||
*/
|
||||
Number,
|
||||
Number = 1 << 1,
|
||||
|
||||
/**
|
||||
* The type of the `true` and `false` literals.
|
||||
*/
|
||||
Boolean,
|
||||
Boolean = 1 << 2,
|
||||
|
||||
/**
|
||||
* The type of the `undefined` literal.
|
||||
*/
|
||||
Undefined,
|
||||
Undefined = 1 << 3,
|
||||
|
||||
/**
|
||||
* the type of the `null` literal.
|
||||
*/
|
||||
Null,
|
||||
Null = 1 << 4,
|
||||
|
||||
/**
|
||||
* the type is an unbound type parameter.
|
||||
*/
|
||||
Unbound,
|
||||
Unbound = 1 << 5,
|
||||
|
||||
/**
|
||||
* Not a built-in type.
|
||||
*/
|
||||
Other
|
||||
Other = 1 << 6,
|
||||
|
||||
Object = 1 << 7,
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user