From d78fa183a31c9d1462e68478a6c74e4767c66211 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 13 Jul 2015 11:15:10 -0700 Subject: [PATCH] Ignore freshness in subtype reduction / Treat Object as {} --- src/compiler/checker.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ca765e387687a..593277428ecfb 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3357,7 +3357,7 @@ namespace ts { // signatures, or if the property is actually declared in the type. In a union or intersection // type, a property is considered known if it is known in any constituent type. function isKnownProperty(type: Type, name: string): boolean { - if (type.flags & TypeFlags.ObjectType) { + if (type.flags & TypeFlags.ObjectType && type !== globalObjectType) { var resolved = resolveStructuredTypeMembers(type); return !!(resolved.properties.length === 0 || resolved.stringIndexType || @@ -3977,7 +3977,7 @@ namespace ts { function isSubtypeOfAny(candidate: Type, types: Type[]): boolean { for (let type of types) { - if (candidate !== type && isTypeSubtypeOf(candidate, type)) { + if (candidate !== type && isTypeSubtypeOf(getRegularTypeOfObjectLiteral(candidate), type)) { return true; } }