From 505c153fed9e45905c8e9d61f7a8d6fae3d11c29 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 29 Nov 2016 16:57:37 -0800 Subject: [PATCH] Simplify isValidSpreadType --- src/compiler/checker.ts | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 56112fe7e86..7dc1ea57708 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11539,21 +11539,9 @@ namespace ts { } function isValidSpreadType(type: Type): boolean { - if (type.flags & (TypeFlags.Any | TypeFlags.Null | TypeFlags.Undefined)) { - return true; - } - if (type.flags & TypeFlags.Object) { - return !isGenericMappedType(type); - } - else if (type.flags & TypeFlags.UnionOrIntersection) { - for (const t of (type).types) { - if (!isValidSpreadType(t)) { - return false; - } - } - return true; - } - return false; + return !!(type.flags & (TypeFlags.Any | TypeFlags.Null | TypeFlags.Undefined) || + type.flags & TypeFlags.Object && !isGenericMappedType(type) || + type.flags & TypeFlags.UnionOrIntersection && !forEach((type).types, t => !isValidSpreadType(t))); } function checkJsxSelfClosingElement(node: JsxSelfClosingElement) {