From b36e5de6f4ce3f7af37ae4d8eaf8e438cdd1a0de Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Wed, 19 Sep 2018 16:21:59 -0700 Subject: [PATCH 1/2] Improve error message for `==` of two different types --- src/compiler/checker.ts | 57 +++- src/compiler/diagnosticMessages.json | 8 + .../unittests/tsserverProjectSystem.ts | 6 +- ...WithNoRelationshipPrimitiveType.errors.txt | 256 +++++++++--------- tests/baselines/reference/expr.errors.txt | 24 +- .../for-inStatementsArrayErrors.errors.txt | 4 +- ...sertionsInEqualityComparisons02.errors.txt | 4 +- .../reference/symbolType9.errors.txt | 16 +- 8 files changed, 209 insertions(+), 166 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 34b72ab36f797..3bb7a51ec2550 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -21955,7 +21955,20 @@ namespace ts { const leftStr = typeToString(leftType); const rightStr = typeToString(rightType); const errNode = errorNode || operatorToken; - if (!tryGiveBetterPrimaryError(errNode, leftStr, rightStr)) { + const equalsInfo = getEqualsInfo(operatorToken.kind); + if (equalsInfo !== undefined) { + const explicitConversion = getExplicitConversion(leftType, rightType); + if (explicitConversion) { + const diag = explicitConversion.side === "left" + ? Diagnostics.Types_0_and_1_have_no_overlap_Consider_explicitly_converting_the_left_side_using_2_x + : Diagnostics.Types_0_and_1_have_no_overlap_Consider_explicitly_converting_the_right_side_using_2_x; + error(errNode, diag, leftStr, rightStr, explicitConversion.conversionFunctionName); + } + else { + error(errNode, Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, String(!equalsInfo), leftStr, rightStr); + } + } + else { error( errNode, Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, @@ -21965,20 +21978,42 @@ namespace ts { ); } } + } - function tryGiveBetterPrimaryError(errNode: Node, leftStr: string, rightStr: string) { - switch (operatorToken.kind) { - case SyntaxKind.EqualsEqualsEqualsToken: - case SyntaxKind.EqualsEqualsToken: - return error(errNode, Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, "false", leftStr, rightStr); - case SyntaxKind.ExclamationEqualsEqualsToken: - case SyntaxKind.ExclamationEqualsToken: - return error(errNode, Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, "true", leftStr, rightStr); - } - return undefined; + function getEqualsInfo(operatorToken: SyntaxKind): boolean | undefined { + switch (operatorToken) { + case SyntaxKind.EqualsEqualsEqualsToken: + case SyntaxKind.EqualsEqualsToken: + return true; + case SyntaxKind.ExclamationEqualsEqualsToken: + case SyntaxKind.ExclamationEqualsToken: + return false; + default: + return undefined; } } + interface ExplicitConversion { + readonly side: "left" | "right"; + readonly conversionFunctionName: string; + } + function getExplicitConversion(left: Type, right: Type): ExplicitConversion | undefined { + const convertLeft = getFunctionNameToConvertToType(right); + if (convertLeft) return { side: "left", conversionFunctionName: convertLeft }; + const convertRight = getFunctionNameToConvertToType(left); + if (convertRight) return { side: "right", conversionFunctionName: convertRight }; + return undefined; + } + function getFunctionNameToConvertToType(type: Type): string | undefined { + return type.flags & TypeFlags.String + ? "String" + : type.flags & TypeFlags.Number + ? "Number" + : type.flags & TypeFlags.Boolean + ? "Boolean" + : undefined; + } + function isYieldExpressionInClass(node: YieldExpression): boolean { let current: Node = node; let parent = node.parent; diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 706a35527653e..4c0e1477d5a5b 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2116,6 +2116,14 @@ "category": "Error", "code": 2586 }, + "Types '{0}' and '{1}' have no overlap. Consider explicitly converting the left side using `{2}(x)`.": { + "category": "Error", + "code": 2587 + }, + "Types '{0}' and '{1}' have no overlap. Consider explicitly converting the right side using `{2}(x)`.": { + "category": "Error", + "code": 2588 + }, "JSX element attributes type '{0}' may not be a union type.": { "category": "Error", "code": 2600 diff --git a/src/testRunner/unittests/tsserverProjectSystem.ts b/src/testRunner/unittests/tsserverProjectSystem.ts index 639cd657e0d73..46ff6288f3578 100644 --- a/src/testRunner/unittests/tsserverProjectSystem.ts +++ b/src/testRunner/unittests/tsserverProjectSystem.ts @@ -5399,7 +5399,7 @@ namespace ts.projectSystem { ); const errorResult = session.executeCommand(getErrRequest).response; assert.isTrue(errorResult.length === 1); - assert.equal(errorResult[0].code, Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap.code); + assert.equal(errorResult[0].code, Diagnostics.Types_0_and_1_have_no_overlap_Consider_explicitly_converting_the_left_side_using_2_x.code); }); it("should report semantic errors for configured js project with '// @ts-check' and skipLibCheck=true", () => { @@ -5426,7 +5426,7 @@ namespace ts.projectSystem { ); const errorResult = session.executeCommand(getErrRequest).response; assert.isTrue(errorResult.length === 1); - assert.equal(errorResult[0].code, Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap.code); + assert.equal(errorResult[0].code, Diagnostics.Types_0_and_1_have_no_overlap_Consider_explicitly_converting_the_left_side_using_2_x.code); }); it("should report semantic errors for configured js project with checkJs=true and skipLibCheck=true", () => { @@ -5455,7 +5455,7 @@ namespace ts.projectSystem { ); const errorResult = session.executeCommand(getErrRequest).response; assert.isTrue(errorResult.length === 1); - assert.equal(errorResult[0].code, Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap.code); + assert.equal(errorResult[0].code, Diagnostics.Types_0_and_1_have_no_overlap_Consider_explicitly_converting_the_left_side_using_2_x.code); }); }); diff --git a/tests/baselines/reference/comparisonOperatorWithNoRelationshipPrimitiveType.errors.txt b/tests/baselines/reference/comparisonOperatorWithNoRelationshipPrimitiveType.errors.txt index 4b2560e3900fb..6bf8bc287011c 100644 --- a/tests/baselines/reference/comparisonOperatorWithNoRelationshipPrimitiveType.errors.txt +++ b/tests/baselines/reference/comparisonOperatorWithNoRelationshipPrimitiveType.errors.txt @@ -70,77 +70,77 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(109,12): error TS2365: Operator '>=' cannot be applied to types 'E' and 'boolean'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(110,12): error TS2365: Operator '>=' cannot be applied to types 'E' and 'string'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(111,12): error TS2365: Operator '>=' cannot be applied to types 'E' and 'void'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(114,12): error TS2367: This condition will always return 'false' since the types 'number' and 'boolean' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(115,12): error TS2367: This condition will always return 'false' since the types 'number' and 'string' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(116,12): error TS2367: This condition will always return 'false' since the types 'number' and 'void' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(119,12): error TS2367: This condition will always return 'false' since the types 'boolean' and 'number' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(120,12): error TS2367: This condition will always return 'false' since the types 'boolean' and 'string' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(121,12): error TS2367: This condition will always return 'false' since the types 'boolean' and 'void' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(122,12): error TS2367: This condition will always return 'false' since the types 'boolean' and 'E' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(124,12): error TS2367: This condition will always return 'false' since the types 'string' and 'number' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(125,12): error TS2367: This condition will always return 'false' since the types 'string' and 'boolean' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(126,12): error TS2367: This condition will always return 'false' since the types 'string' and 'void' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(127,12): error TS2367: This condition will always return 'false' since the types 'string' and 'E' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(129,12): error TS2367: This condition will always return 'false' since the types 'void' and 'number' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(130,12): error TS2367: This condition will always return 'false' since the types 'void' and 'boolean' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(131,12): error TS2367: This condition will always return 'false' since the types 'void' and 'string' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(114,12): error TS2587: Types 'number' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(115,12): error TS2587: Types 'number' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(116,12): error TS2588: Types 'number' and 'void' have no overlap. Consider explicitly converting the right side using `Number(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(119,12): error TS2587: Types 'boolean' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(120,12): error TS2587: Types 'boolean' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(121,12): error TS2588: Types 'boolean' and 'void' have no overlap. Consider explicitly converting the right side using `Boolean(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(122,12): error TS2588: Types 'boolean' and 'E' have no overlap. Consider explicitly converting the right side using `Boolean(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(124,12): error TS2587: Types 'string' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(125,12): error TS2587: Types 'string' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(126,12): error TS2588: Types 'string' and 'void' have no overlap. Consider explicitly converting the right side using `String(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(127,12): error TS2588: Types 'string' and 'E' have no overlap. Consider explicitly converting the right side using `String(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(129,12): error TS2587: Types 'void' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(130,12): error TS2587: Types 'void' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(131,12): error TS2587: Types 'void' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(132,12): error TS2367: This condition will always return 'false' since the types 'void' and 'E' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(135,12): error TS2367: This condition will always return 'false' since the types 'E' and 'boolean' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(136,12): error TS2367: This condition will always return 'false' since the types 'E' and 'string' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(135,12): error TS2587: Types 'E' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(136,12): error TS2587: Types 'E' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(137,12): error TS2367: This condition will always return 'false' since the types 'E' and 'void' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(140,12): error TS2367: This condition will always return 'true' since the types 'number' and 'boolean' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(141,12): error TS2367: This condition will always return 'true' since the types 'number' and 'string' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(142,12): error TS2367: This condition will always return 'true' since the types 'number' and 'void' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(145,12): error TS2367: This condition will always return 'true' since the types 'boolean' and 'number' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(146,12): error TS2367: This condition will always return 'true' since the types 'boolean' and 'string' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(147,12): error TS2367: This condition will always return 'true' since the types 'boolean' and 'void' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(148,12): error TS2367: This condition will always return 'true' since the types 'boolean' and 'E' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(150,12): error TS2367: This condition will always return 'true' since the types 'string' and 'number' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(151,12): error TS2367: This condition will always return 'true' since the types 'string' and 'boolean' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(152,12): error TS2367: This condition will always return 'true' since the types 'string' and 'void' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(153,12): error TS2367: This condition will always return 'true' since the types 'string' and 'E' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(155,12): error TS2367: This condition will always return 'true' since the types 'void' and 'number' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(156,12): error TS2367: This condition will always return 'true' since the types 'void' and 'boolean' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(157,12): error TS2367: This condition will always return 'true' since the types 'void' and 'string' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(140,12): error TS2587: Types 'number' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(141,12): error TS2587: Types 'number' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(142,12): error TS2588: Types 'number' and 'void' have no overlap. Consider explicitly converting the right side using `Number(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(145,12): error TS2587: Types 'boolean' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(146,12): error TS2587: Types 'boolean' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(147,12): error TS2588: Types 'boolean' and 'void' have no overlap. Consider explicitly converting the right side using `Boolean(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(148,12): error TS2588: Types 'boolean' and 'E' have no overlap. Consider explicitly converting the right side using `Boolean(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(150,12): error TS2587: Types 'string' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(151,12): error TS2587: Types 'string' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(152,12): error TS2588: Types 'string' and 'void' have no overlap. Consider explicitly converting the right side using `String(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(153,12): error TS2588: Types 'string' and 'E' have no overlap. Consider explicitly converting the right side using `String(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(155,12): error TS2587: Types 'void' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(156,12): error TS2587: Types 'void' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(157,12): error TS2587: Types 'void' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(158,12): error TS2367: This condition will always return 'true' since the types 'void' and 'E' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(161,12): error TS2367: This condition will always return 'true' since the types 'E' and 'boolean' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(162,12): error TS2367: This condition will always return 'true' since the types 'E' and 'string' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(161,12): error TS2587: Types 'E' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(162,12): error TS2587: Types 'E' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(163,12): error TS2367: This condition will always return 'true' since the types 'E' and 'void' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(166,12): error TS2367: This condition will always return 'false' since the types 'number' and 'boolean' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(167,12): error TS2367: This condition will always return 'false' since the types 'number' and 'string' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(168,12): error TS2367: This condition will always return 'false' since the types 'number' and 'void' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(171,12): error TS2367: This condition will always return 'false' since the types 'boolean' and 'number' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(172,12): error TS2367: This condition will always return 'false' since the types 'boolean' and 'string' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(173,12): error TS2367: This condition will always return 'false' since the types 'boolean' and 'void' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(174,12): error TS2367: This condition will always return 'false' since the types 'boolean' and 'E' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(176,12): error TS2367: This condition will always return 'false' since the types 'string' and 'number' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(177,12): error TS2367: This condition will always return 'false' since the types 'string' and 'boolean' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(178,12): error TS2367: This condition will always return 'false' since the types 'string' and 'void' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(179,12): error TS2367: This condition will always return 'false' since the types 'string' and 'E' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(181,12): error TS2367: This condition will always return 'false' since the types 'void' and 'number' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(182,12): error TS2367: This condition will always return 'false' since the types 'void' and 'boolean' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(183,12): error TS2367: This condition will always return 'false' since the types 'void' and 'string' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(166,12): error TS2587: Types 'number' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(167,12): error TS2587: Types 'number' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(168,12): error TS2588: Types 'number' and 'void' have no overlap. Consider explicitly converting the right side using `Number(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(171,12): error TS2587: Types 'boolean' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(172,12): error TS2587: Types 'boolean' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(173,12): error TS2588: Types 'boolean' and 'void' have no overlap. Consider explicitly converting the right side using `Boolean(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(174,12): error TS2588: Types 'boolean' and 'E' have no overlap. Consider explicitly converting the right side using `Boolean(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(176,12): error TS2587: Types 'string' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(177,12): error TS2587: Types 'string' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(178,12): error TS2588: Types 'string' and 'void' have no overlap. Consider explicitly converting the right side using `String(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(179,12): error TS2588: Types 'string' and 'E' have no overlap. Consider explicitly converting the right side using `String(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(181,12): error TS2587: Types 'void' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(182,12): error TS2587: Types 'void' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(183,12): error TS2587: Types 'void' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(184,12): error TS2367: This condition will always return 'false' since the types 'void' and 'E' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(187,12): error TS2367: This condition will always return 'false' since the types 'E' and 'boolean' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(188,12): error TS2367: This condition will always return 'false' since the types 'E' and 'string' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(187,12): error TS2587: Types 'E' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(188,12): error TS2587: Types 'E' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(189,12): error TS2367: This condition will always return 'false' since the types 'E' and 'void' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(192,12): error TS2367: This condition will always return 'true' since the types 'number' and 'boolean' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(193,12): error TS2367: This condition will always return 'true' since the types 'number' and 'string' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(194,12): error TS2367: This condition will always return 'true' since the types 'number' and 'void' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(197,12): error TS2367: This condition will always return 'true' since the types 'boolean' and 'number' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(198,12): error TS2367: This condition will always return 'true' since the types 'boolean' and 'string' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(199,12): error TS2367: This condition will always return 'true' since the types 'boolean' and 'void' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(200,12): error TS2367: This condition will always return 'true' since the types 'boolean' and 'E' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(202,12): error TS2367: This condition will always return 'true' since the types 'string' and 'number' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(203,12): error TS2367: This condition will always return 'true' since the types 'string' and 'boolean' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(204,12): error TS2367: This condition will always return 'true' since the types 'string' and 'void' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(205,12): error TS2367: This condition will always return 'true' since the types 'string' and 'E' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(207,12): error TS2367: This condition will always return 'true' since the types 'void' and 'number' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(208,12): error TS2367: This condition will always return 'true' since the types 'void' and 'boolean' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(209,12): error TS2367: This condition will always return 'true' since the types 'void' and 'string' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(192,12): error TS2587: Types 'number' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(193,12): error TS2587: Types 'number' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(194,12): error TS2588: Types 'number' and 'void' have no overlap. Consider explicitly converting the right side using `Number(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(197,12): error TS2587: Types 'boolean' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(198,12): error TS2587: Types 'boolean' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(199,12): error TS2588: Types 'boolean' and 'void' have no overlap. Consider explicitly converting the right side using `Boolean(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(200,12): error TS2588: Types 'boolean' and 'E' have no overlap. Consider explicitly converting the right side using `Boolean(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(202,12): error TS2587: Types 'string' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(203,12): error TS2587: Types 'string' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(204,12): error TS2588: Types 'string' and 'void' have no overlap. Consider explicitly converting the right side using `String(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(205,12): error TS2588: Types 'string' and 'E' have no overlap. Consider explicitly converting the right side using `String(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(207,12): error TS2587: Types 'void' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(208,12): error TS2587: Types 'void' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(209,12): error TS2587: Types 'void' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(210,12): error TS2367: This condition will always return 'true' since the types 'void' and 'E' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(213,12): error TS2367: This condition will always return 'true' since the types 'E' and 'boolean' have no overlap. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(214,12): error TS2367: This condition will always return 'true' since the types 'E' and 'string' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(213,12): error TS2587: Types 'E' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(214,12): error TS2587: Types 'E' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(215,12): error TS2367: This condition will always return 'true' since the types 'E' and 'void' have no overlap. @@ -404,50 +404,50 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso // operator == var r5a1 = a == b; ~~~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'number' and 'boolean' have no overlap. +!!! error TS2587: Types 'number' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. var r5a1 = a == c; ~~~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'number' and 'string' have no overlap. +!!! error TS2587: Types 'number' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. var r5a1 = a == d; ~~~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'number' and 'void' have no overlap. +!!! error TS2588: Types 'number' and 'void' have no overlap. Consider explicitly converting the right side using `Number(x)`. var r5a1 = a == e; // no error, expected var r5b1 = b == a; ~~~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'boolean' and 'number' have no overlap. +!!! error TS2587: Types 'boolean' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. var r5b1 = b == c; ~~~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'boolean' and 'string' have no overlap. +!!! error TS2587: Types 'boolean' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. var r5b1 = b == d; ~~~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'boolean' and 'void' have no overlap. +!!! error TS2588: Types 'boolean' and 'void' have no overlap. Consider explicitly converting the right side using `Boolean(x)`. var r5b1 = b == e; ~~~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'boolean' and 'E' have no overlap. +!!! error TS2588: Types 'boolean' and 'E' have no overlap. Consider explicitly converting the right side using `Boolean(x)`. var r5c1 = c == a; ~~~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'string' and 'number' have no overlap. +!!! error TS2587: Types 'string' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. var r5c1 = c == b; ~~~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'string' and 'boolean' have no overlap. +!!! error TS2587: Types 'string' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. var r5c1 = c == d; ~~~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'string' and 'void' have no overlap. +!!! error TS2588: Types 'string' and 'void' have no overlap. Consider explicitly converting the right side using `String(x)`. var r5c1 = c == e; ~~~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'string' and 'E' have no overlap. +!!! error TS2588: Types 'string' and 'E' have no overlap. Consider explicitly converting the right side using `String(x)`. var r5d1 = d == a; ~~~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'void' and 'number' have no overlap. +!!! error TS2587: Types 'void' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. var r5d1 = d == b; ~~~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'void' and 'boolean' have no overlap. +!!! error TS2587: Types 'void' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. var r5d1 = d == c; ~~~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'void' and 'string' have no overlap. +!!! error TS2587: Types 'void' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. var r5d1 = d == e; ~~~~~~ !!! error TS2367: This condition will always return 'false' since the types 'void' and 'E' have no overlap. @@ -455,10 +455,10 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso var r5e1 = e == a; // no error, expected var r5e1 = e == b; ~~~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'E' and 'boolean' have no overlap. +!!! error TS2587: Types 'E' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. var r5e1 = e == c; ~~~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'E' and 'string' have no overlap. +!!! error TS2587: Types 'E' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. var r5e1 = e == d; ~~~~~~ !!! error TS2367: This condition will always return 'false' since the types 'E' and 'void' have no overlap. @@ -466,50 +466,50 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso // operator != var r6a1 = a != b; ~~~~~~ -!!! error TS2367: This condition will always return 'true' since the types 'number' and 'boolean' have no overlap. +!!! error TS2587: Types 'number' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. var r6a1 = a != c; ~~~~~~ -!!! error TS2367: This condition will always return 'true' since the types 'number' and 'string' have no overlap. +!!! error TS2587: Types 'number' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. var r6a1 = a != d; ~~~~~~ -!!! error TS2367: This condition will always return 'true' since the types 'number' and 'void' have no overlap. +!!! error TS2588: Types 'number' and 'void' have no overlap. Consider explicitly converting the right side using `Number(x)`. var r6a1 = a != e; // no error, expected var r6b1 = b != a; ~~~~~~ -!!! error TS2367: This condition will always return 'true' since the types 'boolean' and 'number' have no overlap. +!!! error TS2587: Types 'boolean' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. var r6b1 = b != c; ~~~~~~ -!!! error TS2367: This condition will always return 'true' since the types 'boolean' and 'string' have no overlap. +!!! error TS2587: Types 'boolean' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. var r6b1 = b != d; ~~~~~~ -!!! error TS2367: This condition will always return 'true' since the types 'boolean' and 'void' have no overlap. +!!! error TS2588: Types 'boolean' and 'void' have no overlap. Consider explicitly converting the right side using `Boolean(x)`. var r6b1 = b != e; ~~~~~~ -!!! error TS2367: This condition will always return 'true' since the types 'boolean' and 'E' have no overlap. +!!! error TS2588: Types 'boolean' and 'E' have no overlap. Consider explicitly converting the right side using `Boolean(x)`. var r6c1 = c != a; ~~~~~~ -!!! error TS2367: This condition will always return 'true' since the types 'string' and 'number' have no overlap. +!!! error TS2587: Types 'string' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. var r6c1 = c != b; ~~~~~~ -!!! error TS2367: This condition will always return 'true' since the types 'string' and 'boolean' have no overlap. +!!! error TS2587: Types 'string' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. var r6c1 = c != d; ~~~~~~ -!!! error TS2367: This condition will always return 'true' since the types 'string' and 'void' have no overlap. +!!! error TS2588: Types 'string' and 'void' have no overlap. Consider explicitly converting the right side using `String(x)`. var r6c1 = c != e; ~~~~~~ -!!! error TS2367: This condition will always return 'true' since the types 'string' and 'E' have no overlap. +!!! error TS2588: Types 'string' and 'E' have no overlap. Consider explicitly converting the right side using `String(x)`. var r6d1 = d != a; ~~~~~~ -!!! error TS2367: This condition will always return 'true' since the types 'void' and 'number' have no overlap. +!!! error TS2587: Types 'void' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. var r6d1 = d != b; ~~~~~~ -!!! error TS2367: This condition will always return 'true' since the types 'void' and 'boolean' have no overlap. +!!! error TS2587: Types 'void' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. var r6d1 = d != c; ~~~~~~ -!!! error TS2367: This condition will always return 'true' since the types 'void' and 'string' have no overlap. +!!! error TS2587: Types 'void' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. var r6d1 = d != e; ~~~~~~ !!! error TS2367: This condition will always return 'true' since the types 'void' and 'E' have no overlap. @@ -517,10 +517,10 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso var r6e1 = e != a; // no error, expected var r6e1 = e != b; ~~~~~~ -!!! error TS2367: This condition will always return 'true' since the types 'E' and 'boolean' have no overlap. +!!! error TS2587: Types 'E' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. var r6e1 = e != c; ~~~~~~ -!!! error TS2367: This condition will always return 'true' since the types 'E' and 'string' have no overlap. +!!! error TS2587: Types 'E' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. var r6e1 = e != d; ~~~~~~ !!! error TS2367: This condition will always return 'true' since the types 'E' and 'void' have no overlap. @@ -528,50 +528,50 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso // operator === var r7a1 = a === b; ~~~~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'number' and 'boolean' have no overlap. +!!! error TS2587: Types 'number' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. var r7a1 = a === c; ~~~~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'number' and 'string' have no overlap. +!!! error TS2587: Types 'number' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. var r7a1 = a === d; ~~~~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'number' and 'void' have no overlap. +!!! error TS2588: Types 'number' and 'void' have no overlap. Consider explicitly converting the right side using `Number(x)`. var r7a1 = a === e; // no error, expected var r7b1 = b === a; ~~~~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'boolean' and 'number' have no overlap. +!!! error TS2587: Types 'boolean' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. var r7b1 = b === c; ~~~~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'boolean' and 'string' have no overlap. +!!! error TS2587: Types 'boolean' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. var r7b1 = b === d; ~~~~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'boolean' and 'void' have no overlap. +!!! error TS2588: Types 'boolean' and 'void' have no overlap. Consider explicitly converting the right side using `Boolean(x)`. var r7b1 = b === e; ~~~~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'boolean' and 'E' have no overlap. +!!! error TS2588: Types 'boolean' and 'E' have no overlap. Consider explicitly converting the right side using `Boolean(x)`. var r7c1 = c === a; ~~~~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'string' and 'number' have no overlap. +!!! error TS2587: Types 'string' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. var r7c1 = c === b; ~~~~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'string' and 'boolean' have no overlap. +!!! error TS2587: Types 'string' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. var r7c1 = c === d; ~~~~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'string' and 'void' have no overlap. +!!! error TS2588: Types 'string' and 'void' have no overlap. Consider explicitly converting the right side using `String(x)`. var r7c1 = c === e; ~~~~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'string' and 'E' have no overlap. +!!! error TS2588: Types 'string' and 'E' have no overlap. Consider explicitly converting the right side using `String(x)`. var r7d1 = d === a; ~~~~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'void' and 'number' have no overlap. +!!! error TS2587: Types 'void' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. var r7d1 = d === b; ~~~~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'void' and 'boolean' have no overlap. +!!! error TS2587: Types 'void' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. var r7d1 = d === c; ~~~~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'void' and 'string' have no overlap. +!!! error TS2587: Types 'void' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. var r7d1 = d === e; ~~~~~~~ !!! error TS2367: This condition will always return 'false' since the types 'void' and 'E' have no overlap. @@ -579,10 +579,10 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso var r7e1 = e === a; // no error, expected var r7e1 = e === b; ~~~~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'E' and 'boolean' have no overlap. +!!! error TS2587: Types 'E' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. var r7e1 = e === c; ~~~~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'E' and 'string' have no overlap. +!!! error TS2587: Types 'E' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. var r7e1 = e === d; ~~~~~~~ !!! error TS2367: This condition will always return 'false' since the types 'E' and 'void' have no overlap. @@ -590,50 +590,50 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso // operator !== var r8a1 = a !== b; ~~~~~~~ -!!! error TS2367: This condition will always return 'true' since the types 'number' and 'boolean' have no overlap. +!!! error TS2587: Types 'number' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. var r8a1 = a !== c; ~~~~~~~ -!!! error TS2367: This condition will always return 'true' since the types 'number' and 'string' have no overlap. +!!! error TS2587: Types 'number' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. var r8a1 = a !== d; ~~~~~~~ -!!! error TS2367: This condition will always return 'true' since the types 'number' and 'void' have no overlap. +!!! error TS2588: Types 'number' and 'void' have no overlap. Consider explicitly converting the right side using `Number(x)`. var r8a1 = a !== e; // no error, expected var r8b1 = b !== a; ~~~~~~~ -!!! error TS2367: This condition will always return 'true' since the types 'boolean' and 'number' have no overlap. +!!! error TS2587: Types 'boolean' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. var r8b1 = b !== c; ~~~~~~~ -!!! error TS2367: This condition will always return 'true' since the types 'boolean' and 'string' have no overlap. +!!! error TS2587: Types 'boolean' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. var r8b1 = b !== d; ~~~~~~~ -!!! error TS2367: This condition will always return 'true' since the types 'boolean' and 'void' have no overlap. +!!! error TS2588: Types 'boolean' and 'void' have no overlap. Consider explicitly converting the right side using `Boolean(x)`. var r8b1 = b !== e; ~~~~~~~ -!!! error TS2367: This condition will always return 'true' since the types 'boolean' and 'E' have no overlap. +!!! error TS2588: Types 'boolean' and 'E' have no overlap. Consider explicitly converting the right side using `Boolean(x)`. var r8c1 = c !== a; ~~~~~~~ -!!! error TS2367: This condition will always return 'true' since the types 'string' and 'number' have no overlap. +!!! error TS2587: Types 'string' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. var r8c1 = c !== b; ~~~~~~~ -!!! error TS2367: This condition will always return 'true' since the types 'string' and 'boolean' have no overlap. +!!! error TS2587: Types 'string' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. var r8c1 = c !== d; ~~~~~~~ -!!! error TS2367: This condition will always return 'true' since the types 'string' and 'void' have no overlap. +!!! error TS2588: Types 'string' and 'void' have no overlap. Consider explicitly converting the right side using `String(x)`. var r8c1 = c !== e; ~~~~~~~ -!!! error TS2367: This condition will always return 'true' since the types 'string' and 'E' have no overlap. +!!! error TS2588: Types 'string' and 'E' have no overlap. Consider explicitly converting the right side using `String(x)`. var r8d1 = d !== a; ~~~~~~~ -!!! error TS2367: This condition will always return 'true' since the types 'void' and 'number' have no overlap. +!!! error TS2587: Types 'void' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. var r8d1 = d !== b; ~~~~~~~ -!!! error TS2367: This condition will always return 'true' since the types 'void' and 'boolean' have no overlap. +!!! error TS2587: Types 'void' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. var r8d1 = d !== c; ~~~~~~~ -!!! error TS2367: This condition will always return 'true' since the types 'void' and 'string' have no overlap. +!!! error TS2587: Types 'void' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. var r8d1 = d !== e; ~~~~~~~ !!! error TS2367: This condition will always return 'true' since the types 'void' and 'E' have no overlap. @@ -641,10 +641,10 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso var r8e1 = e !== a; // no error, expected var r8e1 = e !== b; ~~~~~~~ -!!! error TS2367: This condition will always return 'true' since the types 'E' and 'boolean' have no overlap. +!!! error TS2587: Types 'E' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. var r8e1 = e !== c; ~~~~~~~ -!!! error TS2367: This condition will always return 'true' since the types 'E' and 'string' have no overlap. +!!! error TS2587: Types 'E' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. var r8e1 = e !== d; ~~~~~~~ !!! error TS2367: This condition will always return 'true' since the types 'E' and 'void' have no overlap. \ No newline at end of file diff --git a/tests/baselines/reference/expr.errors.txt b/tests/baselines/reference/expr.errors.txt index 05e9ad9c3b476..15eb6aa1361cd 100644 --- a/tests/baselines/reference/expr.errors.txt +++ b/tests/baselines/reference/expr.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/expr.ts(87,5): error TS2367: This condition will always return 'false' since the types 'number' and 'string' have no overlap. -tests/cases/compiler/expr.ts(88,5): error TS2367: This condition will always return 'false' since the types 'number' and 'boolean' have no overlap. -tests/cases/compiler/expr.ts(94,5): error TS2367: This condition will always return 'false' since the types 'string' and 'number' have no overlap. -tests/cases/compiler/expr.ts(95,5): error TS2367: This condition will always return 'false' since the types 'string' and 'boolean' have no overlap. -tests/cases/compiler/expr.ts(98,5): error TS2367: This condition will always return 'false' since the types 'string' and 'E' have no overlap. -tests/cases/compiler/expr.ts(115,5): error TS2367: This condition will always return 'false' since the types 'E' and 'string' have no overlap. +tests/cases/compiler/expr.ts(87,5): error TS2587: Types 'number' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. +tests/cases/compiler/expr.ts(88,5): error TS2587: Types 'number' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. +tests/cases/compiler/expr.ts(94,5): error TS2587: Types 'string' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. +tests/cases/compiler/expr.ts(95,5): error TS2587: Types 'string' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. +tests/cases/compiler/expr.ts(98,5): error TS2588: Types 'string' and 'E' have no overlap. Consider explicitly converting the right side using `String(x)`. +tests/cases/compiler/expr.ts(115,5): error TS2587: Types 'E' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. tests/cases/compiler/expr.ts(116,5): error TS2367: This condition will always return 'false' since the types 'E' and 'false' have no overlap. tests/cases/compiler/expr.ts(142,5): error TS2365: Operator '+' cannot be applied to types 'number' and 'false'. tests/cases/compiler/expr.ts(143,5): error TS2365: Operator '+' cannot be applied to types 'number' and 'I'. @@ -158,10 +158,10 @@ tests/cases/compiler/expr.ts(242,7): error TS2363: The right-hand side of an ari n==a; n==s; ~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'number' and 'string' have no overlap. +!!! error TS2587: Types 'number' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. n==b; ~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'number' and 'boolean' have no overlap. +!!! error TS2587: Types 'number' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. n==i; n==n; n==e; @@ -169,15 +169,15 @@ tests/cases/compiler/expr.ts(242,7): error TS2363: The right-hand side of an ari s==a; s==n; ~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'string' and 'number' have no overlap. +!!! error TS2587: Types 'string' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. s==b; ~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'string' and 'boolean' have no overlap. +!!! error TS2587: Types 'string' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. s==i; s==s; s==e; ~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'string' and 'E' have no overlap. +!!! error TS2588: Types 'string' and 'E' have no overlap. Consider explicitly converting the right side using `String(x)`. a==n; a==s; @@ -196,7 +196,7 @@ tests/cases/compiler/expr.ts(242,7): error TS2363: The right-hand side of an ari e==n; e==s; ~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'E' and 'string' have no overlap. +!!! error TS2587: Types 'E' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. e==b; ~~~~ !!! error TS2367: This condition will always return 'false' since the types 'E' and 'false' have no overlap. diff --git a/tests/baselines/reference/for-inStatementsArrayErrors.errors.txt b/tests/baselines/reference/for-inStatementsArrayErrors.errors.txt index efe6e0985894c..f696ff5dd6228 100644 --- a/tests/baselines/reference/for-inStatementsArrayErrors.errors.txt +++ b/tests/baselines/reference/for-inStatementsArrayErrors.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/statements/for-inStatements/for-inStatementsArrayErrors.ts(4,16): error TS7015: Element implicitly has an 'any' type because index expression is not of type 'number'. tests/cases/conformance/statements/for-inStatements/for-inStatementsArrayErrors.ts(5,16): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. -tests/cases/conformance/statements/for-inStatements/for-inStatementsArrayErrors.ts(6,9): error TS2367: This condition will always return 'false' since the types 'string' and 'number' have no overlap. +tests/cases/conformance/statements/for-inStatements/for-inStatementsArrayErrors.ts(6,9): error TS2587: Types 'string' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. tests/cases/conformance/statements/for-inStatements/for-inStatementsArrayErrors.ts(8,16): error TS2339: Property 'unknownProperty' does not exist on type 'string'. tests/cases/conformance/statements/for-inStatements/for-inStatementsArrayErrors.ts(12,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'i' must be of type 'number', but here has type 'string'. tests/cases/conformance/statements/for-inStatements/for-inStatementsArrayErrors.ts(16,10): error TS2403: Subsequent variable declarations must have the same type. Variable 'j' must be of type 'any', but here has type 'string'. @@ -18,7 +18,7 @@ tests/cases/conformance/statements/for-inStatements/for-inStatementsArrayErrors. !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. if (x === 1) { ~~~~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'string' and 'number' have no overlap. +!!! error TS2587: Types 'string' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. } let a3 = x.unknownProperty; ~~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/stringLiteralsAssertionsInEqualityComparisons02.errors.txt b/tests/baselines/reference/stringLiteralsAssertionsInEqualityComparisons02.errors.txt index 8cb9e8203e7ad..e73b7c7a3df44 100644 --- a/tests/baselines/reference/stringLiteralsAssertionsInEqualityComparisons02.errors.txt +++ b/tests/baselines/reference/stringLiteralsAssertionsInEqualityComparisons02.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/types/literal/stringLiteralsAssertionsInEqualityComparisons02.ts(3,9): error TS2367: This condition will always return 'false' since the types '"foo"' and '"baz"' have no overlap. -tests/cases/conformance/types/literal/stringLiteralsAssertionsInEqualityComparisons02.ts(5,9): error TS2367: This condition will always return 'false' since the types 'string' and 'number' have no overlap. +tests/cases/conformance/types/literal/stringLiteralsAssertionsInEqualityComparisons02.ts(5,9): error TS2587: Types 'string' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. tests/cases/conformance/types/literal/stringLiteralsAssertionsInEqualityComparisons02.ts(5,19): error TS2352: Conversion of type 'string' to type 'number' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. @@ -12,7 +12,7 @@ tests/cases/conformance/types/literal/stringLiteralsAssertionsInEqualityComparis var b = "foo" !== ("bar" as "foo"); var c = "foo" == ("bar"); ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'string' and 'number' have no overlap. +!!! error TS2587: Types 'string' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. ~~~~~~~~~~~~~ !!! error TS2352: Conversion of type 'string' to type 'number' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. var d = "foo" === ("bar" as EnhancedString); \ No newline at end of file diff --git a/tests/baselines/reference/symbolType9.errors.txt b/tests/baselines/reference/symbolType9.errors.txt index 5b6c233367ef2..69f1ead17471c 100644 --- a/tests/baselines/reference/symbolType9.errors.txt +++ b/tests/baselines/reference/symbolType9.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/es6/Symbols/symbolType9.ts(3,1): error TS2367: This condition will always return 'false' since the types 'symbol' and 'boolean' have no overlap. -tests/cases/conformance/es6/Symbols/symbolType9.ts(5,1): error TS2367: This condition will always return 'true' since the types 'number' and 'symbol' have no overlap. -tests/cases/conformance/es6/Symbols/symbolType9.ts(7,1): error TS2367: This condition will always return 'false' since the types 'symbol' and 'number' have no overlap. -tests/cases/conformance/es6/Symbols/symbolType9.ts(9,1): error TS2367: This condition will always return 'true' since the types 'boolean' and 'symbol' have no overlap. +tests/cases/conformance/es6/Symbols/symbolType9.ts(3,1): error TS2587: Types 'symbol' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. +tests/cases/conformance/es6/Symbols/symbolType9.ts(5,1): error TS2588: Types 'number' and 'symbol' have no overlap. Consider explicitly converting the right side using `Number(x)`. +tests/cases/conformance/es6/Symbols/symbolType9.ts(7,1): error TS2587: Types 'symbol' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. +tests/cases/conformance/es6/Symbols/symbolType9.ts(9,1): error TS2588: Types 'boolean' and 'symbol' have no overlap. Consider explicitly converting the right side using `Boolean(x)`. ==== tests/cases/conformance/es6/Symbols/symbolType9.ts (4 errors) ==== @@ -9,16 +9,16 @@ tests/cases/conformance/es6/Symbols/symbolType9.ts(9,1): error TS2367: This cond s == s; s == true; ~~~~~~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'symbol' and 'boolean' have no overlap. +!!! error TS2587: Types 'symbol' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. s != s; 0 != s; ~~~~~~ -!!! error TS2367: This condition will always return 'true' since the types 'number' and 'symbol' have no overlap. +!!! error TS2588: Types 'number' and 'symbol' have no overlap. Consider explicitly converting the right side using `Number(x)`. s === s; s === 1; ~~~~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'symbol' and 'number' have no overlap. +!!! error TS2587: Types 'symbol' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. s !== s; false !== s; ~~~~~~~~~~~ -!!! error TS2367: This condition will always return 'true' since the types 'boolean' and 'symbol' have no overlap. \ No newline at end of file +!!! error TS2588: Types 'boolean' and 'symbol' have no overlap. Consider explicitly converting the right side using `Boolean(x)`. \ No newline at end of file From 107cb982efb3d5423f672bea6e7dc65cb9af16e1 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 20 Sep 2018 14:52:38 -0700 Subject: [PATCH 2/2] Handle literals and literal unions --- src/compiler/checker.ts | 18 ++++-- ...WithNoRelationshipPrimitiveType.errors.txt | 64 +++++++++---------- tests/baselines/reference/expr.errors.txt | 8 +-- 3 files changed, 48 insertions(+), 42 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3bb7a51ec2550..f955114219e02 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -21997,23 +21997,29 @@ namespace ts { readonly side: "left" | "right"; readonly conversionFunctionName: string; } + function getExplicitConversion(left: Type, right: Type): ExplicitConversion | undefined { - const convertLeft = getFunctionNameToConvertToType(right); + const convertLeft = getFunctionNameToConvertToType(right, left); if (convertLeft) return { side: "left", conversionFunctionName: convertLeft }; - const convertRight = getFunctionNameToConvertToType(left); + const convertRight = getFunctionNameToConvertToType(left, right); if (convertRight) return { side: "right", conversionFunctionName: convertRight }; return undefined; } - function getFunctionNameToConvertToType(type: Type): string | undefined { - return type.flags & TypeFlags.String + + function getFunctionNameToConvertToType(to: Type, from: Type): string | undefined { + return typeOrTypesHaveFlags(to, TypeFlags.StringLike) && !typeOrTypesHaveFlags(from, TypeFlags.StringLike) ? "String" - : type.flags & TypeFlags.Number + : typeOrTypesHaveFlags(to, TypeFlags.NumberLike) && !typeOrTypesHaveFlags(from, TypeFlags.NumberLike) ? "Number" - : type.flags & TypeFlags.Boolean + : typeOrTypesHaveFlags(to, TypeFlags.BooleanLike) && !typeOrTypesHaveFlags(from, TypeFlags.BooleanLike) ? "Boolean" : undefined; } + function typeOrTypesHaveFlags(type: Type, flags: TypeFlags): boolean { + return (type.flags & TypeFlags.Union ? (type as UnionType).types : [type]).every(t => !!(t.flags & flags)); + } + function isYieldExpressionInClass(node: YieldExpression): boolean { let current: Node = node; let parent = node.parent; diff --git a/tests/baselines/reference/comparisonOperatorWithNoRelationshipPrimitiveType.errors.txt b/tests/baselines/reference/comparisonOperatorWithNoRelationshipPrimitiveType.errors.txt index 6bf8bc287011c..2a0bda91bdd9f 100644 --- a/tests/baselines/reference/comparisonOperatorWithNoRelationshipPrimitiveType.errors.txt +++ b/tests/baselines/reference/comparisonOperatorWithNoRelationshipPrimitiveType.errors.txt @@ -76,72 +76,72 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(119,12): error TS2587: Types 'boolean' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(120,12): error TS2587: Types 'boolean' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(121,12): error TS2588: Types 'boolean' and 'void' have no overlap. Consider explicitly converting the right side using `Boolean(x)`. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(122,12): error TS2588: Types 'boolean' and 'E' have no overlap. Consider explicitly converting the right side using `Boolean(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(122,12): error TS2587: Types 'boolean' and 'E' have no overlap. Consider explicitly converting the left side using `Number(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(124,12): error TS2587: Types 'string' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(125,12): error TS2587: Types 'string' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(126,12): error TS2588: Types 'string' and 'void' have no overlap. Consider explicitly converting the right side using `String(x)`. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(127,12): error TS2588: Types 'string' and 'E' have no overlap. Consider explicitly converting the right side using `String(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(127,12): error TS2587: Types 'string' and 'E' have no overlap. Consider explicitly converting the left side using `Number(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(129,12): error TS2587: Types 'void' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(130,12): error TS2587: Types 'void' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(131,12): error TS2587: Types 'void' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(132,12): error TS2367: This condition will always return 'false' since the types 'void' and 'E' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(132,12): error TS2587: Types 'void' and 'E' have no overlap. Consider explicitly converting the left side using `Number(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(135,12): error TS2587: Types 'E' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(136,12): error TS2587: Types 'E' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(137,12): error TS2367: This condition will always return 'false' since the types 'E' and 'void' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(137,12): error TS2588: Types 'E' and 'void' have no overlap. Consider explicitly converting the right side using `Number(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(140,12): error TS2587: Types 'number' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(141,12): error TS2587: Types 'number' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(142,12): error TS2588: Types 'number' and 'void' have no overlap. Consider explicitly converting the right side using `Number(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(145,12): error TS2587: Types 'boolean' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(146,12): error TS2587: Types 'boolean' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(147,12): error TS2588: Types 'boolean' and 'void' have no overlap. Consider explicitly converting the right side using `Boolean(x)`. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(148,12): error TS2588: Types 'boolean' and 'E' have no overlap. Consider explicitly converting the right side using `Boolean(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(148,12): error TS2587: Types 'boolean' and 'E' have no overlap. Consider explicitly converting the left side using `Number(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(150,12): error TS2587: Types 'string' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(151,12): error TS2587: Types 'string' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(152,12): error TS2588: Types 'string' and 'void' have no overlap. Consider explicitly converting the right side using `String(x)`. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(153,12): error TS2588: Types 'string' and 'E' have no overlap. Consider explicitly converting the right side using `String(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(153,12): error TS2587: Types 'string' and 'E' have no overlap. Consider explicitly converting the left side using `Number(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(155,12): error TS2587: Types 'void' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(156,12): error TS2587: Types 'void' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(157,12): error TS2587: Types 'void' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(158,12): error TS2367: This condition will always return 'true' since the types 'void' and 'E' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(158,12): error TS2587: Types 'void' and 'E' have no overlap. Consider explicitly converting the left side using `Number(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(161,12): error TS2587: Types 'E' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(162,12): error TS2587: Types 'E' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(163,12): error TS2367: This condition will always return 'true' since the types 'E' and 'void' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(163,12): error TS2588: Types 'E' and 'void' have no overlap. Consider explicitly converting the right side using `Number(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(166,12): error TS2587: Types 'number' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(167,12): error TS2587: Types 'number' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(168,12): error TS2588: Types 'number' and 'void' have no overlap. Consider explicitly converting the right side using `Number(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(171,12): error TS2587: Types 'boolean' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(172,12): error TS2587: Types 'boolean' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(173,12): error TS2588: Types 'boolean' and 'void' have no overlap. Consider explicitly converting the right side using `Boolean(x)`. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(174,12): error TS2588: Types 'boolean' and 'E' have no overlap. Consider explicitly converting the right side using `Boolean(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(174,12): error TS2587: Types 'boolean' and 'E' have no overlap. Consider explicitly converting the left side using `Number(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(176,12): error TS2587: Types 'string' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(177,12): error TS2587: Types 'string' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(178,12): error TS2588: Types 'string' and 'void' have no overlap. Consider explicitly converting the right side using `String(x)`. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(179,12): error TS2588: Types 'string' and 'E' have no overlap. Consider explicitly converting the right side using `String(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(179,12): error TS2587: Types 'string' and 'E' have no overlap. Consider explicitly converting the left side using `Number(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(181,12): error TS2587: Types 'void' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(182,12): error TS2587: Types 'void' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(183,12): error TS2587: Types 'void' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(184,12): error TS2367: This condition will always return 'false' since the types 'void' and 'E' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(184,12): error TS2587: Types 'void' and 'E' have no overlap. Consider explicitly converting the left side using `Number(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(187,12): error TS2587: Types 'E' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(188,12): error TS2587: Types 'E' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(189,12): error TS2367: This condition will always return 'false' since the types 'E' and 'void' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(189,12): error TS2588: Types 'E' and 'void' have no overlap. Consider explicitly converting the right side using `Number(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(192,12): error TS2587: Types 'number' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(193,12): error TS2587: Types 'number' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(194,12): error TS2588: Types 'number' and 'void' have no overlap. Consider explicitly converting the right side using `Number(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(197,12): error TS2587: Types 'boolean' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(198,12): error TS2587: Types 'boolean' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(199,12): error TS2588: Types 'boolean' and 'void' have no overlap. Consider explicitly converting the right side using `Boolean(x)`. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(200,12): error TS2588: Types 'boolean' and 'E' have no overlap. Consider explicitly converting the right side using `Boolean(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(200,12): error TS2587: Types 'boolean' and 'E' have no overlap. Consider explicitly converting the left side using `Number(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(202,12): error TS2587: Types 'string' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(203,12): error TS2587: Types 'string' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(204,12): error TS2588: Types 'string' and 'void' have no overlap. Consider explicitly converting the right side using `String(x)`. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(205,12): error TS2588: Types 'string' and 'E' have no overlap. Consider explicitly converting the right side using `String(x)`. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(205,12): error TS2587: Types 'string' and 'E' have no overlap. Consider explicitly converting the left side using `Number(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(207,12): error TS2587: Types 'void' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(208,12): error TS2587: Types 'void' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(209,12): error TS2587: Types 'void' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(210,12): error TS2367: This condition will always return 'true' since the types 'void' and 'E' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(210,12): error TS2587: Types 'void' and 'E' have no overlap. Consider explicitly converting the left side using `Number(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(213,12): error TS2587: Types 'E' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(214,12): error TS2587: Types 'E' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(215,12): error TS2367: This condition will always return 'true' since the types 'E' and 'void' have no overlap. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(215,12): error TS2588: Types 'E' and 'void' have no overlap. Consider explicitly converting the right side using `Number(x)`. ==== tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts (144 errors) ==== @@ -424,7 +424,7 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso !!! error TS2588: Types 'boolean' and 'void' have no overlap. Consider explicitly converting the right side using `Boolean(x)`. var r5b1 = b == e; ~~~~~~ -!!! error TS2588: Types 'boolean' and 'E' have no overlap. Consider explicitly converting the right side using `Boolean(x)`. +!!! error TS2587: Types 'boolean' and 'E' have no overlap. Consider explicitly converting the left side using `Number(x)`. var r5c1 = c == a; ~~~~~~ @@ -437,7 +437,7 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso !!! error TS2588: Types 'string' and 'void' have no overlap. Consider explicitly converting the right side using `String(x)`. var r5c1 = c == e; ~~~~~~ -!!! error TS2588: Types 'string' and 'E' have no overlap. Consider explicitly converting the right side using `String(x)`. +!!! error TS2587: Types 'string' and 'E' have no overlap. Consider explicitly converting the left side using `Number(x)`. var r5d1 = d == a; ~~~~~~ @@ -450,7 +450,7 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso !!! error TS2587: Types 'void' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. var r5d1 = d == e; ~~~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'void' and 'E' have no overlap. +!!! error TS2587: Types 'void' and 'E' have no overlap. Consider explicitly converting the left side using `Number(x)`. var r5e1 = e == a; // no error, expected var r5e1 = e == b; @@ -461,7 +461,7 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso !!! error TS2587: Types 'E' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. var r5e1 = e == d; ~~~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'E' and 'void' have no overlap. +!!! error TS2588: Types 'E' and 'void' have no overlap. Consider explicitly converting the right side using `Number(x)`. // operator != var r6a1 = a != b; @@ -486,7 +486,7 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso !!! error TS2588: Types 'boolean' and 'void' have no overlap. Consider explicitly converting the right side using `Boolean(x)`. var r6b1 = b != e; ~~~~~~ -!!! error TS2588: Types 'boolean' and 'E' have no overlap. Consider explicitly converting the right side using `Boolean(x)`. +!!! error TS2587: Types 'boolean' and 'E' have no overlap. Consider explicitly converting the left side using `Number(x)`. var r6c1 = c != a; ~~~~~~ @@ -499,7 +499,7 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso !!! error TS2588: Types 'string' and 'void' have no overlap. Consider explicitly converting the right side using `String(x)`. var r6c1 = c != e; ~~~~~~ -!!! error TS2588: Types 'string' and 'E' have no overlap. Consider explicitly converting the right side using `String(x)`. +!!! error TS2587: Types 'string' and 'E' have no overlap. Consider explicitly converting the left side using `Number(x)`. var r6d1 = d != a; ~~~~~~ @@ -512,7 +512,7 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso !!! error TS2587: Types 'void' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. var r6d1 = d != e; ~~~~~~ -!!! error TS2367: This condition will always return 'true' since the types 'void' and 'E' have no overlap. +!!! error TS2587: Types 'void' and 'E' have no overlap. Consider explicitly converting the left side using `Number(x)`. var r6e1 = e != a; // no error, expected var r6e1 = e != b; @@ -523,7 +523,7 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso !!! error TS2587: Types 'E' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. var r6e1 = e != d; ~~~~~~ -!!! error TS2367: This condition will always return 'true' since the types 'E' and 'void' have no overlap. +!!! error TS2588: Types 'E' and 'void' have no overlap. Consider explicitly converting the right side using `Number(x)`. // operator === var r7a1 = a === b; @@ -548,7 +548,7 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso !!! error TS2588: Types 'boolean' and 'void' have no overlap. Consider explicitly converting the right side using `Boolean(x)`. var r7b1 = b === e; ~~~~~~~ -!!! error TS2588: Types 'boolean' and 'E' have no overlap. Consider explicitly converting the right side using `Boolean(x)`. +!!! error TS2587: Types 'boolean' and 'E' have no overlap. Consider explicitly converting the left side using `Number(x)`. var r7c1 = c === a; ~~~~~~~ @@ -561,7 +561,7 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso !!! error TS2588: Types 'string' and 'void' have no overlap. Consider explicitly converting the right side using `String(x)`. var r7c1 = c === e; ~~~~~~~ -!!! error TS2588: Types 'string' and 'E' have no overlap. Consider explicitly converting the right side using `String(x)`. +!!! error TS2587: Types 'string' and 'E' have no overlap. Consider explicitly converting the left side using `Number(x)`. var r7d1 = d === a; ~~~~~~~ @@ -574,7 +574,7 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso !!! error TS2587: Types 'void' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. var r7d1 = d === e; ~~~~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'void' and 'E' have no overlap. +!!! error TS2587: Types 'void' and 'E' have no overlap. Consider explicitly converting the left side using `Number(x)`. var r7e1 = e === a; // no error, expected var r7e1 = e === b; @@ -585,7 +585,7 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso !!! error TS2587: Types 'E' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. var r7e1 = e === d; ~~~~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'E' and 'void' have no overlap. +!!! error TS2588: Types 'E' and 'void' have no overlap. Consider explicitly converting the right side using `Number(x)`. // operator !== var r8a1 = a !== b; @@ -610,7 +610,7 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso !!! error TS2588: Types 'boolean' and 'void' have no overlap. Consider explicitly converting the right side using `Boolean(x)`. var r8b1 = b !== e; ~~~~~~~ -!!! error TS2588: Types 'boolean' and 'E' have no overlap. Consider explicitly converting the right side using `Boolean(x)`. +!!! error TS2587: Types 'boolean' and 'E' have no overlap. Consider explicitly converting the left side using `Number(x)`. var r8c1 = c !== a; ~~~~~~~ @@ -623,7 +623,7 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso !!! error TS2588: Types 'string' and 'void' have no overlap. Consider explicitly converting the right side using `String(x)`. var r8c1 = c !== e; ~~~~~~~ -!!! error TS2588: Types 'string' and 'E' have no overlap. Consider explicitly converting the right side using `String(x)`. +!!! error TS2587: Types 'string' and 'E' have no overlap. Consider explicitly converting the left side using `Number(x)`. var r8d1 = d !== a; ~~~~~~~ @@ -636,7 +636,7 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso !!! error TS2587: Types 'void' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. var r8d1 = d !== e; ~~~~~~~ -!!! error TS2367: This condition will always return 'true' since the types 'void' and 'E' have no overlap. +!!! error TS2587: Types 'void' and 'E' have no overlap. Consider explicitly converting the left side using `Number(x)`. var r8e1 = e !== a; // no error, expected var r8e1 = e !== b; @@ -647,4 +647,4 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso !!! error TS2587: Types 'E' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. var r8e1 = e !== d; ~~~~~~~ -!!! error TS2367: This condition will always return 'true' since the types 'E' and 'void' have no overlap. \ No newline at end of file +!!! error TS2588: Types 'E' and 'void' have no overlap. Consider explicitly converting the right side using `Number(x)`. \ No newline at end of file diff --git a/tests/baselines/reference/expr.errors.txt b/tests/baselines/reference/expr.errors.txt index 15eb6aa1361cd..1e7a50140b461 100644 --- a/tests/baselines/reference/expr.errors.txt +++ b/tests/baselines/reference/expr.errors.txt @@ -2,9 +2,9 @@ tests/cases/compiler/expr.ts(87,5): error TS2587: Types 'number' and 'string' ha tests/cases/compiler/expr.ts(88,5): error TS2587: Types 'number' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. tests/cases/compiler/expr.ts(94,5): error TS2587: Types 'string' and 'number' have no overlap. Consider explicitly converting the left side using `Number(x)`. tests/cases/compiler/expr.ts(95,5): error TS2587: Types 'string' and 'boolean' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. -tests/cases/compiler/expr.ts(98,5): error TS2588: Types 'string' and 'E' have no overlap. Consider explicitly converting the right side using `String(x)`. +tests/cases/compiler/expr.ts(98,5): error TS2587: Types 'string' and 'E' have no overlap. Consider explicitly converting the left side using `Number(x)`. tests/cases/compiler/expr.ts(115,5): error TS2587: Types 'E' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. -tests/cases/compiler/expr.ts(116,5): error TS2367: This condition will always return 'false' since the types 'E' and 'false' have no overlap. +tests/cases/compiler/expr.ts(116,5): error TS2587: Types 'E' and 'false' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. tests/cases/compiler/expr.ts(142,5): error TS2365: Operator '+' cannot be applied to types 'number' and 'false'. tests/cases/compiler/expr.ts(143,5): error TS2365: Operator '+' cannot be applied to types 'number' and 'I'. tests/cases/compiler/expr.ts(161,5): error TS2365: Operator '+' cannot be applied to types 'I' and 'number'. @@ -177,7 +177,7 @@ tests/cases/compiler/expr.ts(242,7): error TS2363: The right-hand side of an ari s==s; s==e; ~~~~ -!!! error TS2588: Types 'string' and 'E' have no overlap. Consider explicitly converting the right side using `String(x)`. +!!! error TS2587: Types 'string' and 'E' have no overlap. Consider explicitly converting the left side using `Number(x)`. a==n; a==s; @@ -199,7 +199,7 @@ tests/cases/compiler/expr.ts(242,7): error TS2363: The right-hand side of an ari !!! error TS2587: Types 'E' and 'string' have no overlap. Consider explicitly converting the left side using `String(x)`. e==b; ~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'E' and 'false' have no overlap. +!!! error TS2587: Types 'E' and 'false' have no overlap. Consider explicitly converting the left side using `Boolean(x)`. e==a; e==i; e==e;