Avoid checking for optionality in comparability checks.

This commit is contained in:
Daniel Rosenwasser 2016-11-12 12:59:43 -08:00
parent 2edabe0ae0
commit 375437ef3c

View File

@ -7331,7 +7331,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..