From 375437ef3cb149d49b560b0b30aa5c305b9c6eaa Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Sat, 12 Nov 2016 12:59:43 -0800 Subject: [PATCH] Avoid checking for optionality in comparability checks. --- src/compiler/checker.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 789f2bd8104..6be5c1c453f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -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..