From 42c49cea0d1b393ab57bf748ae1c3bb42e00ca57 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 4 Nov 2015 13:05:46 -0800 Subject: [PATCH] Style. --- src/compiler/checker.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9d069a547d9..f16722b7c57 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4882,13 +4882,13 @@ namespace ts { let saveErrorInfo = errorInfo; - // Note that the "each" checks must precede the "some" checks to produce the correct results + // Note that these checks are specifically ordered to produce correct results. if (source.flags & TypeFlags.Union) { if (relation === comparableRelation) { result = someTypeRelatedToType(source as UnionType, target, reportErrors); } else { - result = eachTypeRelatedToType(source, target, reportErrors); + result = eachTypeRelatedToType(source as UnionType, target, reportErrors); } if (result) { @@ -4896,25 +4896,25 @@ namespace ts { } } else if (target.flags & TypeFlags.Intersection) { - result = typeRelatedToEachType(source, target, reportErrors); + result = typeRelatedToEachType(source, target as IntersectionType, reportErrors); if (result) { return result; } } else { - // It is necessary to try "some" checks on both sides because there may be nested "each" checks + // It is necessary to try these "some" checks on both sides because there may be nested "each" checks // on either side that need to be prioritized. For example, A | B = (A | B) & (C | D) or // A & B = (A & B) | (C & D). if (source.flags & TypeFlags.Intersection) { // If target is a union type then the check following this one will report errors, // so we'll suppress any errors we could run into here. - if (result = someTypeRelatedToType(source, target, reportErrors && !(target.flags & TypeFlags.Union))) { + if (result = someTypeRelatedToType(source as IntersectionType, target, reportErrors && !(target.flags & TypeFlags.Union))) { return result; } } if (target.flags & TypeFlags.Union) { - if (result = typeRelatedToSomeType(source, target, reportErrors)) { + if (result = typeRelatedToSomeType(source, target as UnionType, reportErrors)) { return result; } } @@ -12727,6 +12727,7 @@ namespace ts { let caseClause = clause; // TypeScript 1.0 spec (April 2014): 5.9 // In a 'switch' statement, each 'case' expression must be of a type that is assignable to or from the type of the 'switch' expression. + // TODO (drosen): this needs to be amended to reflect the "comparable" relationship. let caseType = checkExpression(caseClause.expression); if (!isTypeComparableTo(expressionType, caseType)) {