From 51787e3daa0481537c1fb7733b65b335751da3a5 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 13 Jan 2016 23:12:41 -0800 Subject: [PATCH] Don't report structural errors on primitive apparent types. --- src/compiler/checker.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index bfee2d68a5c..28748805ffa 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5240,7 +5240,9 @@ namespace ts { // relates to X. Thus, we include intersection types on the source side here. if (apparentType.flags & (TypeFlags.ObjectType | TypeFlags.Intersection) && target.flags & TypeFlags.ObjectType) { // Report structural errors only if we haven't reported any errors yet - const reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo ? ReportErrors.Elaborate : ReportErrors.None; + const reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !isPrimitiveApparentType(apparentType) + ? ReportErrors.Elaborate + : ReportErrors.None; if (result = objectTypeRelatedTo(apparentType, source, target, reportStructuralErrors)) { errorInfo = saveErrorInfo; return result; @@ -5629,7 +5631,7 @@ namespace ts { } // don't elaborate the primitive apparent types (like Number) // because the actual primitives will have already been reported. - if (shouldElaborateErrors && !isPrimitiveApparentType(source)) { + if (shouldElaborateErrors) { reportError(Diagnostics.Type_0_provides_no_match_for_the_signature_1, typeToString(source), signatureToString(t, /*enclosingDeclaration*/ undefined, /*flags*/ undefined, kind));