From 11ff2a5c62a837e2dc848d6b4831360f771fe445 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 9 Feb 2023 10:05:23 -0800 Subject: [PATCH 1/5] Add test --- .../mixedTypeEnumComparison.errors.txt | 27 +++++++++ .../reference/mixedTypeEnumComparison.js | 31 ++++++++++ .../reference/mixedTypeEnumComparison.symbols | 50 ++++++++++++++++ .../reference/mixedTypeEnumComparison.types | 58 +++++++++++++++++++ .../cases/compiler/mixedTypeEnumComparison.ts | 22 +++++++ 5 files changed, 188 insertions(+) create mode 100644 tests/baselines/reference/mixedTypeEnumComparison.errors.txt create mode 100644 tests/baselines/reference/mixedTypeEnumComparison.js create mode 100644 tests/baselines/reference/mixedTypeEnumComparison.symbols create mode 100644 tests/baselines/reference/mixedTypeEnumComparison.types create mode 100644 tests/cases/compiler/mixedTypeEnumComparison.ts diff --git a/tests/baselines/reference/mixedTypeEnumComparison.errors.txt b/tests/baselines/reference/mixedTypeEnumComparison.errors.txt new file mode 100644 index 0000000000000..360eacfead7b0 --- /dev/null +++ b/tests/baselines/reference/mixedTypeEnumComparison.errors.txt @@ -0,0 +1,27 @@ +tests/cases/compiler/mixedTypeEnumComparison.ts(11,5): error TS2365: Operator '>' cannot be applied to types 'number' and 'E'. + + +==== tests/cases/compiler/mixedTypeEnumComparison.ts (1 errors) ==== + const enum E { + S1 = "foo", + S2 = "bar", + + N1 = 1000, + N2 = 25, + } + + declare var someNumber: number + + if (someNumber > E.N2) { + ~~~~~~~~~~~~~~~~~ +!!! error TS2365: Operator '>' cannot be applied to types 'number' and 'E'. + someNumber = E.N2; + } + + declare var someString: string + + if (someString > E.S1) { + someString = E.S2; + } + + \ No newline at end of file diff --git a/tests/baselines/reference/mixedTypeEnumComparison.js b/tests/baselines/reference/mixedTypeEnumComparison.js new file mode 100644 index 0000000000000..4c6185835859f --- /dev/null +++ b/tests/baselines/reference/mixedTypeEnumComparison.js @@ -0,0 +1,31 @@ +//// [mixedTypeEnumComparison.ts] +const enum E { + S1 = "foo", + S2 = "bar", + + N1 = 1000, + N2 = 25, +} + +declare var someNumber: number + +if (someNumber > E.N2) { + someNumber = E.N2; +} + +declare var someString: string + +if (someString > E.S1) { + someString = E.S2; +} + + + +//// [mixedTypeEnumComparison.js] +"use strict"; +if (someNumber > 25 /* E.N2 */) { + someNumber = 25 /* E.N2 */; +} +if (someString > "foo" /* E.S1 */) { + someString = "bar" /* E.S2 */; +} diff --git a/tests/baselines/reference/mixedTypeEnumComparison.symbols b/tests/baselines/reference/mixedTypeEnumComparison.symbols new file mode 100644 index 0000000000000..bdc85bc02fa3e --- /dev/null +++ b/tests/baselines/reference/mixedTypeEnumComparison.symbols @@ -0,0 +1,50 @@ +=== tests/cases/compiler/mixedTypeEnumComparison.ts === +const enum E { +>E : Symbol(E, Decl(mixedTypeEnumComparison.ts, 0, 0)) + + S1 = "foo", +>S1 : Symbol(E.S1, Decl(mixedTypeEnumComparison.ts, 0, 14)) + + S2 = "bar", +>S2 : Symbol(E.S2, Decl(mixedTypeEnumComparison.ts, 1, 15)) + + N1 = 1000, +>N1 : Symbol(E.N1, Decl(mixedTypeEnumComparison.ts, 2, 15)) + + N2 = 25, +>N2 : Symbol(E.N2, Decl(mixedTypeEnumComparison.ts, 4, 14)) +} + +declare var someNumber: number +>someNumber : Symbol(someNumber, Decl(mixedTypeEnumComparison.ts, 8, 11)) + +if (someNumber > E.N2) { +>someNumber : Symbol(someNumber, Decl(mixedTypeEnumComparison.ts, 8, 11)) +>E.N2 : Symbol(E.N2, Decl(mixedTypeEnumComparison.ts, 4, 14)) +>E : Symbol(E, Decl(mixedTypeEnumComparison.ts, 0, 0)) +>N2 : Symbol(E.N2, Decl(mixedTypeEnumComparison.ts, 4, 14)) + + someNumber = E.N2; +>someNumber : Symbol(someNumber, Decl(mixedTypeEnumComparison.ts, 8, 11)) +>E.N2 : Symbol(E.N2, Decl(mixedTypeEnumComparison.ts, 4, 14)) +>E : Symbol(E, Decl(mixedTypeEnumComparison.ts, 0, 0)) +>N2 : Symbol(E.N2, Decl(mixedTypeEnumComparison.ts, 4, 14)) +} + +declare var someString: string +>someString : Symbol(someString, Decl(mixedTypeEnumComparison.ts, 14, 11)) + +if (someString > E.S1) { +>someString : Symbol(someString, Decl(mixedTypeEnumComparison.ts, 14, 11)) +>E.S1 : Symbol(E.S1, Decl(mixedTypeEnumComparison.ts, 0, 14)) +>E : Symbol(E, Decl(mixedTypeEnumComparison.ts, 0, 0)) +>S1 : Symbol(E.S1, Decl(mixedTypeEnumComparison.ts, 0, 14)) + + someString = E.S2; +>someString : Symbol(someString, Decl(mixedTypeEnumComparison.ts, 14, 11)) +>E.S2 : Symbol(E.S2, Decl(mixedTypeEnumComparison.ts, 1, 15)) +>E : Symbol(E, Decl(mixedTypeEnumComparison.ts, 0, 0)) +>S2 : Symbol(E.S2, Decl(mixedTypeEnumComparison.ts, 1, 15)) +} + + diff --git a/tests/baselines/reference/mixedTypeEnumComparison.types b/tests/baselines/reference/mixedTypeEnumComparison.types new file mode 100644 index 0000000000000..28f400a5ea939 --- /dev/null +++ b/tests/baselines/reference/mixedTypeEnumComparison.types @@ -0,0 +1,58 @@ +=== tests/cases/compiler/mixedTypeEnumComparison.ts === +const enum E { +>E : E + + S1 = "foo", +>S1 : E.S1 +>"foo" : "foo" + + S2 = "bar", +>S2 : E.S2 +>"bar" : "bar" + + N1 = 1000, +>N1 : E.N1 +>1000 : 1000 + + N2 = 25, +>N2 : E.N2 +>25 : 25 +} + +declare var someNumber: number +>someNumber : number + +if (someNumber > E.N2) { +>someNumber > E.N2 : boolean +>someNumber : number +>E.N2 : E.N2 +>E : typeof E +>N2 : E.N2 + + someNumber = E.N2; +>someNumber = E.N2 : E.N2 +>someNumber : number +>E.N2 : E.N2 +>E : typeof E +>N2 : E.N2 +} + +declare var someString: string +>someString : string + +if (someString > E.S1) { +>someString > E.S1 : boolean +>someString : string +>E.S1 : E.S1 +>E : typeof E +>S1 : E.S1 + + someString = E.S2; +>someString = E.S2 : E.S2 +>someString : string +>E.S2 : E.S2 +>E : typeof E +>S2 : E.S2 +} + + diff --git a/tests/cases/compiler/mixedTypeEnumComparison.ts b/tests/cases/compiler/mixedTypeEnumComparison.ts new file mode 100644 index 0000000000000..5391e6dba53b1 --- /dev/null +++ b/tests/cases/compiler/mixedTypeEnumComparison.ts @@ -0,0 +1,22 @@ +// @strict: true + +const enum E { + S1 = "foo", + S2 = "bar", + + N1 = 1000, + N2 = 25, +} + +declare var someNumber: number + +if (someNumber > E.N2) { + someNumber = E.N2; +} + +declare var someString: string + +if (someString > E.S1) { + someString = E.S2; +} + From d7cefaf0d0943e61952ee5f1e5e124197b5b76cc Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 9 Feb 2023 10:08:42 -0800 Subject: [PATCH 2/5] Prefer using enum literal's own base type rather than enum's base type in comparison --- src/compiler/checker.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5200b9b4cafde..fdea3ad6f2194 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -22978,6 +22978,18 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { type; } + // This is the same as getBaseTypeOfLiteralType, but checks EnumLiteral last so we get + // a specific literal's base type rather than the enum's base type. + function getBaseTypeOfLiteralTypeForComparison(type: Type): Type { + return type.flags & (TypeFlags.StringLiteral | TypeFlags.TemplateLiteral | TypeFlags.StringMapping) ? stringType : + type.flags & TypeFlags.NumberLiteral ? numberType : + type.flags & TypeFlags.BigIntLiteral ? bigintType : + type.flags & TypeFlags.BooleanLiteral ? booleanType : + type.flags & TypeFlags.EnumLiteral ? getBaseTypeOfEnumLiteralType(type as LiteralType) : + type.flags & TypeFlags.Union ? getBaseTypeOfLiteralTypeUnion(type as UnionType) : + type; + } + function getBaseTypeOfLiteralTypeUnion(type: UnionType) { const key = `B${getTypeId(type)}`; return getCachedType(key) ?? setCachedType(key, mapType(type, getBaseTypeOfLiteralType)); @@ -36423,8 +36435,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { case SyntaxKind.LessThanEqualsToken: case SyntaxKind.GreaterThanEqualsToken: if (checkForDisallowedESSymbolOperand(operator)) { - leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); - rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); + leftType = getBaseTypeOfLiteralTypeForComparison(checkNonNullType(leftType, left)); + rightType = getBaseTypeOfLiteralTypeForComparison(checkNonNullType(rightType, right)); reportOperatorErrorUnless((left, right) => { if (isTypeAny(left) || isTypeAny(right)) { return true; From e80855148037f82b0ccfb5a0b7d2149263a6c649 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 9 Feb 2023 10:15:37 -0800 Subject: [PATCH 3/5] Fix unions --- src/compiler/checker.ts | 13 ++++++--- .../mixedTypeEnumComparison.errors.txt | 27 ------------------- .../reference/mixedTypeEnumComparison.js | 9 +++++++ .../reference/mixedTypeEnumComparison.symbols | 24 ++++++++++++++--- .../reference/mixedTypeEnumComparison.types | 18 +++++++++++++ .../cases/compiler/mixedTypeEnumComparison.ts | 6 +++++ 6 files changed, 63 insertions(+), 34 deletions(-) delete mode 100644 tests/baselines/reference/mixedTypeEnumComparison.errors.txt diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index fdea3ad6f2194..34734c6b7d185 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -22978,6 +22978,11 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { type; } + function getBaseTypeOfLiteralTypeUnion(type: UnionType) { + const key = `B${getTypeId(type)}`; + return getCachedType(key) ?? setCachedType(key, mapType(type, getBaseTypeOfLiteralType)); + } + // This is the same as getBaseTypeOfLiteralType, but checks EnumLiteral last so we get // a specific literal's base type rather than the enum's base type. function getBaseTypeOfLiteralTypeForComparison(type: Type): Type { @@ -22986,13 +22991,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { type.flags & TypeFlags.BigIntLiteral ? bigintType : type.flags & TypeFlags.BooleanLiteral ? booleanType : type.flags & TypeFlags.EnumLiteral ? getBaseTypeOfEnumLiteralType(type as LiteralType) : - type.flags & TypeFlags.Union ? getBaseTypeOfLiteralTypeUnion(type as UnionType) : + type.flags & TypeFlags.Union ? getBaseTypeOfLiteralTypeUnionForComparison(type as UnionType) : type; } - function getBaseTypeOfLiteralTypeUnion(type: UnionType) { - const key = `B${getTypeId(type)}`; - return getCachedType(key) ?? setCachedType(key, mapType(type, getBaseTypeOfLiteralType)); + function getBaseTypeOfLiteralTypeUnionForComparison(type: UnionType) { + const key = `BC${getTypeId(type)}`; + return getCachedType(key) ?? setCachedType(key, mapType(type, getBaseTypeOfLiteralTypeForComparison)); } function getWidenedLiteralType(type: Type): Type { diff --git a/tests/baselines/reference/mixedTypeEnumComparison.errors.txt b/tests/baselines/reference/mixedTypeEnumComparison.errors.txt deleted file mode 100644 index 360eacfead7b0..0000000000000 --- a/tests/baselines/reference/mixedTypeEnumComparison.errors.txt +++ /dev/null @@ -1,27 +0,0 @@ -tests/cases/compiler/mixedTypeEnumComparison.ts(11,5): error TS2365: Operator '>' cannot be applied to types 'number' and 'E'. - - -==== tests/cases/compiler/mixedTypeEnumComparison.ts (1 errors) ==== - const enum E { - S1 = "foo", - S2 = "bar", - - N1 = 1000, - N2 = 25, - } - - declare var someNumber: number - - if (someNumber > E.N2) { - ~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '>' cannot be applied to types 'number' and 'E'. - someNumber = E.N2; - } - - declare var someString: string - - if (someString > E.S1) { - someString = E.S2; - } - - \ No newline at end of file diff --git a/tests/baselines/reference/mixedTypeEnumComparison.js b/tests/baselines/reference/mixedTypeEnumComparison.js index 4c6185835859f..97470894ca470 100644 --- a/tests/baselines/reference/mixedTypeEnumComparison.js +++ b/tests/baselines/reference/mixedTypeEnumComparison.js @@ -13,6 +13,12 @@ if (someNumber > E.N2) { someNumber = E.N2; } +declare const unionOfEnum: E.N1 | E.N2; + +if (someNumber > unionOfEnum) { + someNumber = E.N2; +} + declare var someString: string if (someString > E.S1) { @@ -26,6 +32,9 @@ if (someString > E.S1) { if (someNumber > 25 /* E.N2 */) { someNumber = 25 /* E.N2 */; } +if (someNumber > unionOfEnum) { + someNumber = 25 /* E.N2 */; +} if (someString > "foo" /* E.S1 */) { someString = "bar" /* E.S2 */; } diff --git a/tests/baselines/reference/mixedTypeEnumComparison.symbols b/tests/baselines/reference/mixedTypeEnumComparison.symbols index bdc85bc02fa3e..7f5f852ba6a31 100644 --- a/tests/baselines/reference/mixedTypeEnumComparison.symbols +++ b/tests/baselines/reference/mixedTypeEnumComparison.symbols @@ -31,17 +31,35 @@ if (someNumber > E.N2) { >N2 : Symbol(E.N2, Decl(mixedTypeEnumComparison.ts, 4, 14)) } +declare const unionOfEnum: E.N1 | E.N2; +>unionOfEnum : Symbol(unionOfEnum, Decl(mixedTypeEnumComparison.ts, 14, 13)) +>E : Symbol(E, Decl(mixedTypeEnumComparison.ts, 0, 0)) +>N1 : Symbol(E.N1, Decl(mixedTypeEnumComparison.ts, 2, 15)) +>E : Symbol(E, Decl(mixedTypeEnumComparison.ts, 0, 0)) +>N2 : Symbol(E.N2, Decl(mixedTypeEnumComparison.ts, 4, 14)) + +if (someNumber > unionOfEnum) { +>someNumber : Symbol(someNumber, Decl(mixedTypeEnumComparison.ts, 8, 11)) +>unionOfEnum : Symbol(unionOfEnum, Decl(mixedTypeEnumComparison.ts, 14, 13)) + + someNumber = E.N2; +>someNumber : Symbol(someNumber, Decl(mixedTypeEnumComparison.ts, 8, 11)) +>E.N2 : Symbol(E.N2, Decl(mixedTypeEnumComparison.ts, 4, 14)) +>E : Symbol(E, Decl(mixedTypeEnumComparison.ts, 0, 0)) +>N2 : Symbol(E.N2, Decl(mixedTypeEnumComparison.ts, 4, 14)) +} + declare var someString: string ->someString : Symbol(someString, Decl(mixedTypeEnumComparison.ts, 14, 11)) +>someString : Symbol(someString, Decl(mixedTypeEnumComparison.ts, 20, 11)) if (someString > E.S1) { ->someString : Symbol(someString, Decl(mixedTypeEnumComparison.ts, 14, 11)) +>someString : Symbol(someString, Decl(mixedTypeEnumComparison.ts, 20, 11)) >E.S1 : Symbol(E.S1, Decl(mixedTypeEnumComparison.ts, 0, 14)) >E : Symbol(E, Decl(mixedTypeEnumComparison.ts, 0, 0)) >S1 : Symbol(E.S1, Decl(mixedTypeEnumComparison.ts, 0, 14)) someString = E.S2; ->someString : Symbol(someString, Decl(mixedTypeEnumComparison.ts, 14, 11)) +>someString : Symbol(someString, Decl(mixedTypeEnumComparison.ts, 20, 11)) >E.S2 : Symbol(E.S2, Decl(mixedTypeEnumComparison.ts, 1, 15)) >E : Symbol(E, Decl(mixedTypeEnumComparison.ts, 0, 0)) >S2 : Symbol(E.S2, Decl(mixedTypeEnumComparison.ts, 1, 15)) diff --git a/tests/baselines/reference/mixedTypeEnumComparison.types b/tests/baselines/reference/mixedTypeEnumComparison.types index 28f400a5ea939..a6f8c9fddba05 100644 --- a/tests/baselines/reference/mixedTypeEnumComparison.types +++ b/tests/baselines/reference/mixedTypeEnumComparison.types @@ -37,6 +37,24 @@ if (someNumber > E.N2) { >N2 : E.N2 } +declare const unionOfEnum: E.N1 | E.N2; +>unionOfEnum : E.N1 | E.N2 +>E : any +>E : any + +if (someNumber > unionOfEnum) { +>someNumber > unionOfEnum : boolean +>someNumber : number +>unionOfEnum : E.N1 | E.N2 + + someNumber = E.N2; +>someNumber = E.N2 : E.N2 +>someNumber : number +>E.N2 : E.N2 +>E : typeof E +>N2 : E.N2 +} + declare var someString: string >someString : string diff --git a/tests/cases/compiler/mixedTypeEnumComparison.ts b/tests/cases/compiler/mixedTypeEnumComparison.ts index 5391e6dba53b1..aebdf508d6512 100644 --- a/tests/cases/compiler/mixedTypeEnumComparison.ts +++ b/tests/cases/compiler/mixedTypeEnumComparison.ts @@ -14,6 +14,12 @@ if (someNumber > E.N2) { someNumber = E.N2; } +declare const unionOfEnum: E.N1 | E.N2; + +if (someNumber > unionOfEnum) { + someNumber = E.N2; +} + declare var someString: string if (someString > E.S1) { From ce188e2ce73d77f9616ebc98ef0e5200a8bda760 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 15 Feb 2023 18:57:02 -0800 Subject: [PATCH 4/5] PR feedback --- src/compiler/checker.ts | 10 +- ...WithNoRelationshipPrimitiveType.errors.txt | 96 +++++++++---------- ...WithNoRelationshipTypeParameter.errors.txt | 64 ++++++------- .../reference/mixedTypeEnumComparison.js | 23 ++++- .../reference/mixedTypeEnumComparison.symbols | 37 ++++++- .../reference/mixedTypeEnumComparison.types | 43 ++++++++- .../cases/compiler/mixedTypeEnumComparison.ts | 14 ++- 7 files changed, 195 insertions(+), 92 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 34734c6b7d185..f4726e9a725ac 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -22987,19 +22987,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // a specific literal's base type rather than the enum's base type. function getBaseTypeOfLiteralTypeForComparison(type: Type): Type { return type.flags & (TypeFlags.StringLiteral | TypeFlags.TemplateLiteral | TypeFlags.StringMapping) ? stringType : - type.flags & TypeFlags.NumberLiteral ? numberType : + type.flags & (TypeFlags.NumberLiteral | TypeFlags.Enum) ? numberType : type.flags & TypeFlags.BigIntLiteral ? bigintType : type.flags & TypeFlags.BooleanLiteral ? booleanType : - type.flags & TypeFlags.EnumLiteral ? getBaseTypeOfEnumLiteralType(type as LiteralType) : - type.flags & TypeFlags.Union ? getBaseTypeOfLiteralTypeUnionForComparison(type as UnionType) : + type.flags & TypeFlags.Union ? mapType(type, getBaseTypeOfLiteralTypeForComparison) : type; } - function getBaseTypeOfLiteralTypeUnionForComparison(type: UnionType) { - const key = `BC${getTypeId(type)}`; - return getCachedType(key) ?? setCachedType(key, mapType(type, getBaseTypeOfLiteralTypeForComparison)); - } - function getWidenedLiteralType(type: Type): Type { return type.flags & TypeFlags.EnumLiteral && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type as LiteralType) : type.flags & TypeFlags.StringLiteral && isFreshLiteralType(type) ? stringType : diff --git a/tests/baselines/reference/comparisonOperatorWithNoRelationshipPrimitiveType.errors.txt b/tests/baselines/reference/comparisonOperatorWithNoRelationshipPrimitiveType.errors.txt index a3565efb99e13..df66c774218c7 100644 --- a/tests/baselines/reference/comparisonOperatorWithNoRelationshipPrimitiveType.errors.txt +++ b/tests/baselines/reference/comparisonOperatorWithNoRelationshipPrimitiveType.errors.txt @@ -4,72 +4,72 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(15,12): error TS2365: Operator '<' cannot be applied to types 'boolean' and 'number'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(16,12): error TS2365: Operator '<' cannot be applied to types 'boolean' and 'string'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(17,12): error TS2365: Operator '<' cannot be applied to types 'boolean' and 'void'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(18,12): error TS2365: Operator '<' cannot be applied to types 'boolean' and 'E'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(18,12): error TS2365: Operator '<' cannot be applied to types 'boolean' and 'number'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(20,12): error TS2365: Operator '<' cannot be applied to types 'string' and 'number'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(21,12): error TS2365: Operator '<' cannot be applied to types 'string' and 'boolean'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(22,12): error TS2365: Operator '<' cannot be applied to types 'string' and 'void'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(23,12): error TS2365: Operator '<' cannot be applied to types 'string' and 'E'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(23,12): error TS2365: Operator '<' cannot be applied to types 'string' and 'number'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(25,12): error TS2365: Operator '<' cannot be applied to types 'void' and 'number'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(26,12): error TS2365: Operator '<' cannot be applied to types 'void' and 'boolean'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(27,12): error TS2365: Operator '<' cannot be applied to types 'void' and 'string'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(28,12): error TS2365: Operator '<' cannot be applied to types 'void' and 'E'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(31,12): error TS2365: Operator '<' cannot be applied to types 'E' and 'boolean'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(32,12): error TS2365: Operator '<' cannot be applied to types 'E' and 'string'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(33,12): error TS2365: Operator '<' cannot be applied to types 'E' and 'void'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(28,12): error TS2365: Operator '<' cannot be applied to types 'void' and 'number'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(31,12): error TS2365: Operator '<' cannot be applied to types 'number' and 'boolean'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(32,12): error TS2365: Operator '<' cannot be applied to types 'number' and 'string'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(33,12): error TS2365: Operator '<' cannot be applied to types 'number' and 'void'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(36,12): error TS2365: Operator '>' cannot be applied to types 'number' and 'boolean'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(37,12): error TS2365: Operator '>' cannot be applied to types 'number' and 'string'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(38,12): error TS2365: Operator '>' cannot be applied to types 'number' and 'void'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(41,12): error TS2365: Operator '>' cannot be applied to types 'boolean' and 'number'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(42,12): error TS2365: Operator '>' cannot be applied to types 'boolean' and 'string'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(43,12): error TS2365: Operator '>' cannot be applied to types 'boolean' and 'void'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(44,12): error TS2365: Operator '>' cannot be applied to types 'boolean' and 'E'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(44,12): error TS2365: Operator '>' cannot be applied to types 'boolean' and 'number'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(46,12): error TS2365: Operator '>' cannot be applied to types 'string' and 'number'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(47,12): error TS2365: Operator '>' cannot be applied to types 'string' and 'boolean'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(48,12): error TS2365: Operator '>' cannot be applied to types 'string' and 'void'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(49,12): error TS2365: Operator '>' cannot be applied to types 'string' and 'E'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(49,12): error TS2365: Operator '>' cannot be applied to types 'string' and 'number'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(51,12): error TS2365: Operator '>' cannot be applied to types 'void' and 'number'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(52,12): error TS2365: Operator '>' cannot be applied to types 'void' and 'boolean'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(53,12): error TS2365: Operator '>' cannot be applied to types 'void' and 'string'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(54,12): error TS2365: Operator '>' cannot be applied to types 'void' and 'E'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(57,12): error TS2365: Operator '>' cannot be applied to types 'E' and 'boolean'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(58,12): error TS2365: Operator '>' cannot be applied to types 'E' and 'string'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(59,12): error TS2365: Operator '>' cannot be applied to types 'E' and 'void'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(54,12): error TS2365: Operator '>' cannot be applied to types 'void' and 'number'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(57,12): error TS2365: Operator '>' cannot be applied to types 'number' and 'boolean'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(58,12): error TS2365: Operator '>' cannot be applied to types 'number' and 'string'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(59,12): error TS2365: Operator '>' cannot be applied to types 'number' and 'void'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(62,12): error TS2365: Operator '<=' cannot be applied to types 'number' and 'boolean'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(63,12): error TS2365: Operator '<=' cannot be applied to types 'number' and 'string'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(64,12): error TS2365: Operator '<=' cannot be applied to types 'number' and 'void'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(67,12): error TS2365: Operator '<=' cannot be applied to types 'boolean' and 'number'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(68,12): error TS2365: Operator '<=' cannot be applied to types 'boolean' and 'string'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(69,12): error TS2365: Operator '<=' cannot be applied to types 'boolean' and 'void'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(70,12): error TS2365: Operator '<=' cannot be applied to types 'boolean' and 'E'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(70,12): error TS2365: Operator '<=' cannot be applied to types 'boolean' and 'number'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(72,12): error TS2365: Operator '<=' cannot be applied to types 'string' and 'number'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(73,12): error TS2365: Operator '<=' cannot be applied to types 'string' and 'boolean'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(74,12): error TS2365: Operator '<=' cannot be applied to types 'string' and 'void'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(75,12): error TS2365: Operator '<=' cannot be applied to types 'string' and 'E'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(75,12): error TS2365: Operator '<=' cannot be applied to types 'string' and 'number'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(77,12): error TS2365: Operator '<=' cannot be applied to types 'void' and 'number'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(78,12): error TS2365: Operator '<=' cannot be applied to types 'void' and 'boolean'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(79,12): error TS2365: Operator '<=' cannot be applied to types 'void' and 'string'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(80,12): error TS2365: Operator '<=' cannot be applied to types 'void' and 'E'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(83,12): error TS2365: Operator '<=' cannot be applied to types 'E' and 'boolean'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(84,12): error TS2365: Operator '<=' cannot be applied to types 'E' and 'string'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(85,12): error TS2365: Operator '<=' cannot be applied to types 'E' and 'void'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(80,12): error TS2365: Operator '<=' cannot be applied to types 'void' and 'number'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(83,12): error TS2365: Operator '<=' cannot be applied to types 'number' and 'boolean'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(84,12): error TS2365: Operator '<=' cannot be applied to types 'number' and 'string'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(85,12): error TS2365: Operator '<=' cannot be applied to types 'number' and 'void'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(88,12): error TS2365: Operator '>=' cannot be applied to types 'number' and 'boolean'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(89,12): error TS2365: Operator '>=' cannot be applied to types 'number' and 'string'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(90,12): error TS2365: Operator '>=' cannot be applied to types 'number' and 'void'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(93,12): error TS2365: Operator '>=' cannot be applied to types 'boolean' and 'number'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(94,12): error TS2365: Operator '>=' cannot be applied to types 'boolean' and 'string'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(95,12): error TS2365: Operator '>=' cannot be applied to types 'boolean' and 'void'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(96,12): error TS2365: Operator '>=' cannot be applied to types 'boolean' and 'E'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(96,12): error TS2365: Operator '>=' cannot be applied to types 'boolean' and 'number'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(98,12): error TS2365: Operator '>=' cannot be applied to types 'string' and 'number'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(99,12): error TS2365: Operator '>=' cannot be applied to types 'string' and 'boolean'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(100,12): error TS2365: Operator '>=' cannot be applied to types 'string' and 'void'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(101,12): error TS2365: Operator '>=' cannot be applied to types 'string' and 'E'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(101,12): error TS2365: Operator '>=' cannot be applied to types 'string' and 'number'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(103,12): error TS2365: Operator '>=' cannot be applied to types 'void' and 'number'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(104,12): error TS2365: Operator '>=' cannot be applied to types 'void' and 'boolean'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(105,12): error TS2365: Operator '>=' cannot be applied to types 'void' and 'string'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(106,12): error TS2365: Operator '>=' cannot be applied to types 'void' and 'E'. -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(106,12): error TS2365: Operator '>=' cannot be applied to types 'void' and 'number'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(109,12): error TS2365: Operator '>=' cannot be applied to types 'number' and 'boolean'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(110,12): error TS2365: Operator '>=' cannot be applied to types 'number' and 'string'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(111,12): error TS2365: Operator '>=' cannot be applied to types 'number' and 'void'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(114,12): error TS2367: This comparison appears to be unintentional because the types 'number' and 'boolean' have no overlap. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(115,12): error TS2367: This comparison appears to be unintentional because the types 'number' and 'string' have no overlap. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipPrimitiveType.ts(116,12): error TS2367: This comparison appears to be unintentional because the types 'number' and 'void' have no overlap. @@ -176,7 +176,7 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso !!! error TS2365: Operator '<' cannot be applied to types 'boolean' and 'void'. var r1b1 = b < e; ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types 'boolean' and 'E'. +!!! error TS2365: Operator '<' cannot be applied to types 'boolean' and 'number'. var r1c1 = c < a; ~~~~~ @@ -189,7 +189,7 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso !!! error TS2365: Operator '<' cannot be applied to types 'string' and 'void'. var r1c1 = c < e; ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types 'string' and 'E'. +!!! error TS2365: Operator '<' cannot be applied to types 'string' and 'number'. var r1d1 = d < a; ~~~~~ @@ -202,18 +202,18 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso !!! error TS2365: Operator '<' cannot be applied to types 'void' and 'string'. var r1d1 = d < e; ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types 'void' and 'E'. +!!! error TS2365: Operator '<' cannot be applied to types 'void' and 'number'. var r1e1 = e < a; // no error, expected var r1e1 = e < b; ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types 'E' and 'boolean'. +!!! error TS2365: Operator '<' cannot be applied to types 'number' and 'boolean'. var r1e1 = e < c; ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types 'E' and 'string'. +!!! error TS2365: Operator '<' cannot be applied to types 'number' and 'string'. var r1e1 = e < d; ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types 'E' and 'void'. +!!! error TS2365: Operator '<' cannot be applied to types 'number' and 'void'. // operator > var r2a1 = a > b; @@ -238,7 +238,7 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso !!! error TS2365: Operator '>' cannot be applied to types 'boolean' and 'void'. var r2b1 = b > e; ~~~~~ -!!! error TS2365: Operator '>' cannot be applied to types 'boolean' and 'E'. +!!! error TS2365: Operator '>' cannot be applied to types 'boolean' and 'number'. var r2c1 = c > a; ~~~~~ @@ -251,7 +251,7 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso !!! error TS2365: Operator '>' cannot be applied to types 'string' and 'void'. var r2c1 = c > e; ~~~~~ -!!! error TS2365: Operator '>' cannot be applied to types 'string' and 'E'. +!!! error TS2365: Operator '>' cannot be applied to types 'string' and 'number'. var r2d1 = d > a; ~~~~~ @@ -264,18 +264,18 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso !!! error TS2365: Operator '>' cannot be applied to types 'void' and 'string'. var r2d1 = d > e; ~~~~~ -!!! error TS2365: Operator '>' cannot be applied to types 'void' and 'E'. +!!! error TS2365: Operator '>' cannot be applied to types 'void' and 'number'. var r2e1 = e > a; // no error, expected var r2e1 = e > b; ~~~~~ -!!! error TS2365: Operator '>' cannot be applied to types 'E' and 'boolean'. +!!! error TS2365: Operator '>' cannot be applied to types 'number' and 'boolean'. var r2e1 = e > c; ~~~~~ -!!! error TS2365: Operator '>' cannot be applied to types 'E' and 'string'. +!!! error TS2365: Operator '>' cannot be applied to types 'number' and 'string'. var r2e1 = e > d; ~~~~~ -!!! error TS2365: Operator '>' cannot be applied to types 'E' and 'void'. +!!! error TS2365: Operator '>' cannot be applied to types 'number' and 'void'. // operator <= var r3a1 = a <= b; @@ -300,7 +300,7 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso !!! error TS2365: Operator '<=' cannot be applied to types 'boolean' and 'void'. var r3b1 = b <= e; ~~~~~~ -!!! error TS2365: Operator '<=' cannot be applied to types 'boolean' and 'E'. +!!! error TS2365: Operator '<=' cannot be applied to types 'boolean' and 'number'. var r3c1 = c <= a; ~~~~~~ @@ -313,7 +313,7 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso !!! error TS2365: Operator '<=' cannot be applied to types 'string' and 'void'. var r3c1 = c <= e; ~~~~~~ -!!! error TS2365: Operator '<=' cannot be applied to types 'string' and 'E'. +!!! error TS2365: Operator '<=' cannot be applied to types 'string' and 'number'. var r3d1 = d <= a; ~~~~~~ @@ -326,18 +326,18 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso !!! error TS2365: Operator '<=' cannot be applied to types 'void' and 'string'. var r3d1 = d <= e; ~~~~~~ -!!! error TS2365: Operator '<=' cannot be applied to types 'void' and 'E'. +!!! error TS2365: Operator '<=' cannot be applied to types 'void' and 'number'. var r3e1 = e <= a; // no error, expected var r3e1 = e <= b; ~~~~~~ -!!! error TS2365: Operator '<=' cannot be applied to types 'E' and 'boolean'. +!!! error TS2365: Operator '<=' cannot be applied to types 'number' and 'boolean'. var r3e1 = e <= c; ~~~~~~ -!!! error TS2365: Operator '<=' cannot be applied to types 'E' and 'string'. +!!! error TS2365: Operator '<=' cannot be applied to types 'number' and 'string'. var r3e1 = e <= d; ~~~~~~ -!!! error TS2365: Operator '<=' cannot be applied to types 'E' and 'void'. +!!! error TS2365: Operator '<=' cannot be applied to types 'number' and 'void'. // operator >= var r4a1 = a >= b; @@ -362,7 +362,7 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso !!! error TS2365: Operator '>=' cannot be applied to types 'boolean' and 'void'. var r4b1 = b >= e; ~~~~~~ -!!! error TS2365: Operator '>=' cannot be applied to types 'boolean' and 'E'. +!!! error TS2365: Operator '>=' cannot be applied to types 'boolean' and 'number'. var r4c1 = c >= a; ~~~~~~ @@ -375,7 +375,7 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso !!! error TS2365: Operator '>=' cannot be applied to types 'string' and 'void'. var r4c1 = c >= e; ~~~~~~ -!!! error TS2365: Operator '>=' cannot be applied to types 'string' and 'E'. +!!! error TS2365: Operator '>=' cannot be applied to types 'string' and 'number'. var r4d1 = d >= a; ~~~~~~ @@ -388,18 +388,18 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso !!! error TS2365: Operator '>=' cannot be applied to types 'void' and 'string'. var r4d1 = d >= e; ~~~~~~ -!!! error TS2365: Operator '>=' cannot be applied to types 'void' and 'E'. +!!! error TS2365: Operator '>=' cannot be applied to types 'void' and 'number'. var r4e1 = e >= a; // no error, expected var r4e1 = e >= b; ~~~~~~ -!!! error TS2365: Operator '>=' cannot be applied to types 'E' and 'boolean'. +!!! error TS2365: Operator '>=' cannot be applied to types 'number' and 'boolean'. var r4e1 = e >= c; ~~~~~~ -!!! error TS2365: Operator '>=' cannot be applied to types 'E' and 'string'. +!!! error TS2365: Operator '>=' cannot be applied to types 'number' and 'string'. var r4e1 = e >= d; ~~~~~~ -!!! error TS2365: Operator '>=' cannot be applied to types 'E' and 'void'. +!!! error TS2365: Operator '>=' cannot be applied to types 'number' and 'void'. // operator == var r5a1 = a == b; diff --git a/tests/baselines/reference/comparisonOperatorWithNoRelationshipTypeParameter.errors.txt b/tests/baselines/reference/comparisonOperatorWithNoRelationshipTypeParameter.errors.txt index de8a8ac3ce14c..165403a7c2ea2 100644 --- a/tests/baselines/reference/comparisonOperatorWithNoRelationshipTypeParameter.errors.txt +++ b/tests/baselines/reference/comparisonOperatorWithNoRelationshipTypeParameter.errors.txt @@ -7,37 +7,37 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(18,14): error TS2367: This comparison appears to be unintentional because the types 'T' and 'U' have no overlap. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(19,14): error TS2367: This comparison appears to be unintentional because the types 'T' and 'U' have no overlap. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(23,16): error TS2365: Operator '<' cannot be applied to types 'T' and 'number'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(26,16): error TS2365: Operator '<' cannot be applied to types 'T' and 'E'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(26,16): error TS2365: Operator '<' cannot be applied to types 'T' and 'number'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(31,16): error TS2365: Operator '<' cannot be applied to types 'number' and 'T'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(34,16): error TS2365: Operator '<' cannot be applied to types 'E' and 'T'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(34,16): error TS2365: Operator '<' cannot be applied to types 'number' and 'T'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(40,16): error TS2365: Operator '<' cannot be applied to types 'T' and 'number'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(43,16): error TS2365: Operator '<' cannot be applied to types 'T' and 'E'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(43,16): error TS2365: Operator '<' cannot be applied to types 'T' and 'number'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(48,16): error TS2365: Operator '<' cannot be applied to types 'number' and 'T'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(51,16): error TS2365: Operator '<' cannot be applied to types 'E' and 'T'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(51,16): error TS2365: Operator '<' cannot be applied to types 'number' and 'T'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(57,16): error TS2365: Operator '<' cannot be applied to types 'T' and 'number'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(60,16): error TS2365: Operator '<' cannot be applied to types 'T' and 'E'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(60,16): error TS2365: Operator '<' cannot be applied to types 'T' and 'number'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(65,16): error TS2365: Operator '<' cannot be applied to types 'number' and 'T'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(68,16): error TS2365: Operator '<' cannot be applied to types 'E' and 'T'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(68,16): error TS2365: Operator '<' cannot be applied to types 'number' and 'T'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(74,16): error TS2365: Operator '<' cannot be applied to types 'T' and 'number'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(77,16): error TS2365: Operator '<' cannot be applied to types 'T' and 'E'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(77,16): error TS2365: Operator '<' cannot be applied to types 'T' and 'number'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(82,16): error TS2365: Operator '<' cannot be applied to types 'number' and 'T'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(85,16): error TS2365: Operator '<' cannot be applied to types 'E' and 'T'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(85,16): error TS2365: Operator '<' cannot be applied to types 'number' and 'T'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(91,16): error TS2365: Operator '<' cannot be applied to types 'T' and 'number'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(94,16): error TS2365: Operator '<' cannot be applied to types 'T' and 'E'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(94,16): error TS2365: Operator '<' cannot be applied to types 'T' and 'number'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(99,16): error TS2365: Operator '<' cannot be applied to types 'number' and 'T'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(102,16): error TS2365: Operator '<' cannot be applied to types 'E' and 'T'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(102,16): error TS2365: Operator '<' cannot be applied to types 'number' and 'T'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(108,16): error TS2365: Operator '<' cannot be applied to types 'T' and 'number'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(111,16): error TS2365: Operator '<' cannot be applied to types 'T' and 'E'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(111,16): error TS2365: Operator '<' cannot be applied to types 'T' and 'number'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(116,16): error TS2365: Operator '<' cannot be applied to types 'number' and 'T'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(119,16): error TS2365: Operator '<' cannot be applied to types 'E' and 'T'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(119,16): error TS2365: Operator '<' cannot be applied to types 'number' and 'T'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(125,16): error TS2365: Operator '<' cannot be applied to types 'T' and 'number'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(128,16): error TS2365: Operator '<' cannot be applied to types 'T' and 'E'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(128,16): error TS2365: Operator '<' cannot be applied to types 'T' and 'number'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(133,16): error TS2365: Operator '<' cannot be applied to types 'number' and 'T'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(136,16): error TS2365: Operator '<' cannot be applied to types 'E' and 'T'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(136,16): error TS2365: Operator '<' cannot be applied to types 'number' and 'T'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(142,16): error TS2365: Operator '<' cannot be applied to types 'T' and 'number'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(145,16): error TS2365: Operator '<' cannot be applied to types 'T' and 'E'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(145,16): error TS2365: Operator '<' cannot be applied to types 'T' and 'number'. tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(150,16): error TS2365: Operator '<' cannot be applied to types 'number' and 'T'. -tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(153,16): error TS2365: Operator '<' cannot be applied to types 'E' and 'T'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts(153,16): error TS2365: Operator '<' cannot be applied to types 'number' and 'T'. ==== tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNoRelationshipTypeParameter.ts (40 errors) ==== @@ -86,7 +86,7 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso var r1a4 = t < d; var r1a5 = t < e; ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types 'T' and 'E'. +!!! error TS2365: Operator '<' cannot be applied to types 'T' and 'number'. var r1a6 = t < f; var r1a7 = t < g; @@ -98,7 +98,7 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso var r1b4 = d < t; var r1b5 = e < t; ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types 'E' and 'T'. +!!! error TS2365: Operator '<' cannot be applied to types 'number' and 'T'. var r1b6 = f < t; var r1b7 = g < t; @@ -111,7 +111,7 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso var r2a4 = t < d; var r2a5 = t < e; ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types 'T' and 'E'. +!!! error TS2365: Operator '<' cannot be applied to types 'T' and 'number'. var r2a6 = t < f; var r2a7 = t < g; @@ -123,7 +123,7 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso var r2b4 = d < t; var r2b5 = e < t; ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types 'E' and 'T'. +!!! error TS2365: Operator '<' cannot be applied to types 'number' and 'T'. var r2b6 = f < t; var r2b7 = g < t; @@ -136,7 +136,7 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso var r3a4 = t < d; var r3a5 = t < e; ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types 'T' and 'E'. +!!! error TS2365: Operator '<' cannot be applied to types 'T' and 'number'. var r3a6 = t < f; var r3a7 = t < g; @@ -148,7 +148,7 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso var r3b4 = d < t; var r3b5 = e < t; ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types 'E' and 'T'. +!!! error TS2365: Operator '<' cannot be applied to types 'number' and 'T'. var r3b6 = f < t; var r3b7 = g < t; @@ -161,7 +161,7 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso var r4a4 = t < d; var r4a5 = t < e; ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types 'T' and 'E'. +!!! error TS2365: Operator '<' cannot be applied to types 'T' and 'number'. var r4a6 = t < f; var r4a7 = t < g; @@ -173,7 +173,7 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso var r4b4 = d < t; var r4b5 = e < t; ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types 'E' and 'T'. +!!! error TS2365: Operator '<' cannot be applied to types 'number' and 'T'. var r4b6 = f < t; var r4b7 = g < t; @@ -186,7 +186,7 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso var r5a4 = t < d; var r5a5 = t < e; ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types 'T' and 'E'. +!!! error TS2365: Operator '<' cannot be applied to types 'T' and 'number'. var r5a6 = t < f; var r5a7 = t < g; @@ -198,7 +198,7 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso var r5b4 = d < t; var r5b5 = e < t; ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types 'E' and 'T'. +!!! error TS2365: Operator '<' cannot be applied to types 'number' and 'T'. var r5b6 = f < t; var r5b7 = g < t; @@ -211,7 +211,7 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso var r6a4 = t < d; var r6a5 = t < e; ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types 'T' and 'E'. +!!! error TS2365: Operator '<' cannot be applied to types 'T' and 'number'. var r6a6 = t < f; var r6a7 = t < g; @@ -223,7 +223,7 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso var r6b4 = d < t; var r6b5 = e < t; ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types 'E' and 'T'. +!!! error TS2365: Operator '<' cannot be applied to types 'number' and 'T'. var r6b6 = f < t; var r6b7 = g < t; @@ -236,7 +236,7 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso var r7a4 = t < d; var r7a5 = t < e; ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types 'T' and 'E'. +!!! error TS2365: Operator '<' cannot be applied to types 'T' and 'number'. var r7a6 = t < f; var r7a7 = t < g; @@ -248,7 +248,7 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso var r7b4 = d < t; var r7b5 = e < t; ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types 'E' and 'T'. +!!! error TS2365: Operator '<' cannot be applied to types 'number' and 'T'. var r7b6 = f < t; var r7b7 = g < t; @@ -261,7 +261,7 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso var r8a4 = t < d; var r8a5 = t < e; ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types 'T' and 'E'. +!!! error TS2365: Operator '<' cannot be applied to types 'T' and 'number'. var r8a6 = t < f; var r8a7 = t < g; @@ -273,7 +273,7 @@ tests/cases/conformance/expressions/binaryOperators/comparisonOperator/compariso var r8b4 = d < t; var r8b5 = e < t; ~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types 'E' and 'T'. +!!! error TS2365: Operator '<' cannot be applied to types 'number' and 'T'. var r8b6 = f < t; var r8b7 = g < t; } \ No newline at end of file diff --git a/tests/baselines/reference/mixedTypeEnumComparison.js b/tests/baselines/reference/mixedTypeEnumComparison.js index 97470894ca470..b461f67f0e828 100644 --- a/tests/baselines/reference/mixedTypeEnumComparison.js +++ b/tests/baselines/reference/mixedTypeEnumComparison.js @@ -2,7 +2,7 @@ const enum E { S1 = "foo", S2 = "bar", - + N1 = 1000, N2 = 25, } @@ -25,6 +25,18 @@ if (someString > E.S1) { someString = E.S2; } + +declare function someValue(): number; + +enum E2 { + S1 = "foo", + N1 = 1000, + C1 = someValue(), +} + +someString > E2.S1; +someNumber > E2.N1; +someNumber > E2.C1; //// [mixedTypeEnumComparison.js] @@ -38,3 +50,12 @@ if (someNumber > unionOfEnum) { if (someString > "foo" /* E.S1 */) { someString = "bar" /* E.S2 */; } +var E2; +(function (E2) { + E2["S1"] = "foo"; + E2[E2["N1"] = 1000] = "N1"; + E2[E2["C1"] = someValue()] = "C1"; +})(E2 || (E2 = {})); +someString > E2.S1; +someNumber > E2.N1; +someNumber > E2.C1; diff --git a/tests/baselines/reference/mixedTypeEnumComparison.symbols b/tests/baselines/reference/mixedTypeEnumComparison.symbols index 7f5f852ba6a31..7d0f087848295 100644 --- a/tests/baselines/reference/mixedTypeEnumComparison.symbols +++ b/tests/baselines/reference/mixedTypeEnumComparison.symbols @@ -7,7 +7,7 @@ const enum E { S2 = "bar", >S2 : Symbol(E.S2, Decl(mixedTypeEnumComparison.ts, 1, 15)) - + N1 = 1000, >N1 : Symbol(E.N1, Decl(mixedTypeEnumComparison.ts, 2, 15)) @@ -66,3 +66,38 @@ if (someString > E.S1) { } +declare function someValue(): number; +>someValue : Symbol(someValue, Decl(mixedTypeEnumComparison.ts, 24, 1)) + +enum E2 { +>E2 : Symbol(E2, Decl(mixedTypeEnumComparison.ts, 27, 37)) + + S1 = "foo", +>S1 : Symbol(E2.S1, Decl(mixedTypeEnumComparison.ts, 29, 9)) + + N1 = 1000, +>N1 : Symbol(E2.N1, Decl(mixedTypeEnumComparison.ts, 30, 15)) + + C1 = someValue(), +>C1 : Symbol(E2.C1, Decl(mixedTypeEnumComparison.ts, 31, 14)) +>someValue : Symbol(someValue, Decl(mixedTypeEnumComparison.ts, 24, 1)) +} + +someString > E2.S1; +>someString : Symbol(someString, Decl(mixedTypeEnumComparison.ts, 20, 11)) +>E2.S1 : Symbol(E2.S1, Decl(mixedTypeEnumComparison.ts, 29, 9)) +>E2 : Symbol(E2, Decl(mixedTypeEnumComparison.ts, 27, 37)) +>S1 : Symbol(E2.S1, Decl(mixedTypeEnumComparison.ts, 29, 9)) + +someNumber > E2.N1; +>someNumber : Symbol(someNumber, Decl(mixedTypeEnumComparison.ts, 8, 11)) +>E2.N1 : Symbol(E2.N1, Decl(mixedTypeEnumComparison.ts, 30, 15)) +>E2 : Symbol(E2, Decl(mixedTypeEnumComparison.ts, 27, 37)) +>N1 : Symbol(E2.N1, Decl(mixedTypeEnumComparison.ts, 30, 15)) + +someNumber > E2.C1; +>someNumber : Symbol(someNumber, Decl(mixedTypeEnumComparison.ts, 8, 11)) +>E2.C1 : Symbol(E2.C1, Decl(mixedTypeEnumComparison.ts, 31, 14)) +>E2 : Symbol(E2, Decl(mixedTypeEnumComparison.ts, 27, 37)) +>C1 : Symbol(E2.C1, Decl(mixedTypeEnumComparison.ts, 31, 14)) + diff --git a/tests/baselines/reference/mixedTypeEnumComparison.types b/tests/baselines/reference/mixedTypeEnumComparison.types index a6f8c9fddba05..3f9c1cb44fc08 100644 --- a/tests/baselines/reference/mixedTypeEnumComparison.types +++ b/tests/baselines/reference/mixedTypeEnumComparison.types @@ -9,7 +9,7 @@ const enum E { S2 = "bar", >S2 : E.S2 >"bar" : "bar" - + N1 = 1000, >N1 : E.N1 >1000 : 1000 @@ -74,3 +74,44 @@ if (someString > E.S1) { } +declare function someValue(): number; +>someValue : () => number + +enum E2 { +>E2 : E2 + + S1 = "foo", +>S1 : E2.S1 +>"foo" : "foo" + + N1 = 1000, +>N1 : E2.N1 +>1000 : 1000 + + C1 = someValue(), +>C1 : E2.C1 +>someValue() : number +>someValue : () => number +} + +someString > E2.S1; +>someString > E2.S1 : boolean +>someString : string +>E2.S1 : E2.S1 +>E2 : typeof E2 +>S1 : E2.S1 + +someNumber > E2.N1; +>someNumber > E2.N1 : boolean +>someNumber : number +>E2.N1 : E2.N1 +>E2 : typeof E2 +>N1 : E2.N1 + +someNumber > E2.C1; +>someNumber > E2.C1 : boolean +>someNumber : number +>E2.C1 : E2.C1 +>E2 : typeof E2 +>C1 : E2.C1 + diff --git a/tests/cases/compiler/mixedTypeEnumComparison.ts b/tests/cases/compiler/mixedTypeEnumComparison.ts index aebdf508d6512..7baa6d77b4717 100644 --- a/tests/cases/compiler/mixedTypeEnumComparison.ts +++ b/tests/cases/compiler/mixedTypeEnumComparison.ts @@ -3,7 +3,7 @@ const enum E { S1 = "foo", S2 = "bar", - + N1 = 1000, N2 = 25, } @@ -26,3 +26,15 @@ if (someString > E.S1) { someString = E.S2; } + +declare function someValue(): number; + +enum E2 { + S1 = "foo", + N1 = 1000, + C1 = someValue(), +} + +someString > E2.S1; +someNumber > E2.N1; +someNumber > E2.C1; From 31a617123107682f0e95ea3898ba552802853bab Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 15 Feb 2023 18:59:24 -0800 Subject: [PATCH 5/5] Reword comment --- src/compiler/checker.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f4726e9a725ac..1427ee3a1fc86 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -22983,8 +22983,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return getCachedType(key) ?? setCachedType(key, mapType(type, getBaseTypeOfLiteralType)); } - // This is the same as getBaseTypeOfLiteralType, but checks EnumLiteral last so we get - // a specific literal's base type rather than the enum's base type. + // This like getBaseTypeOfLiteralType, but instead treats enum literals as strings/numbers instead + // of returning their enum base type (which depends on the types of other literals in the enum). function getBaseTypeOfLiteralTypeForComparison(type: Type): Type { return type.flags & (TypeFlags.StringLiteral | TypeFlags.TemplateLiteral | TypeFlags.StringMapping) ? stringType : type.flags & (TypeFlags.NumberLiteral | TypeFlags.Enum) ? numberType :