Ignore optionality in the comparable relationship (#12202)

* Added tests.

* Accepted baselines.

* Avoid checking for optionality in comparability checks.

* Accepted baselines.
This commit is contained in:
Mohamed Hegazy
2016-11-14 10:47:48 -08:00
committed by GitHub
9 changed files with 160 additions and 1 deletions

View File

@@ -7536,7 +7536,8 @@ namespace ts {
return Ternary.False;
}
result &= related;
if (sourceProp.flags & SymbolFlags.Optional && !(targetProp.flags & SymbolFlags.Optional)) {
// When checking for comparability, be more lenient with optional properties.
if (relation !== comparableRelation && sourceProp.flags & SymbolFlags.Optional && !(targetProp.flags & SymbolFlags.Optional)) {
// TypeScript 1.0 spec (April 2014): 3.8.3
// S is a subtype of a type T, and T is a supertype of S if ...
// S' and T are object types and, for each member M in T..