diff --git a/tests/baselines/reference/comparisonOperatorWithNumericLiteral.errors.txt b/tests/baselines/reference/comparisonOperatorWithNumericLiteral.errors.txt new file mode 100644 index 0000000000000..d863ca29090b8 --- /dev/null +++ b/tests/baselines/reference/comparisonOperatorWithNumericLiteral.errors.txt @@ -0,0 +1,58 @@ +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNumericLiteral.ts(5,1): error TS2365: Operator '>' cannot be applied to types 'BrandedNum' and '0'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNumericLiteral.ts(10,1): error TS2365: Operator '<' cannot be applied to types 'BrandedNum' and '0'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNumericLiteral.ts(15,1): error TS2365: Operator '>=' cannot be applied to types 'BrandedNum' and '0'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNumericLiteral.ts(20,1): error TS2365: Operator '<=' cannot be applied to types 'BrandedNum' and '0'. + + +==== tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNumericLiteral.ts (4 errors) ==== + type BrandedNum = number & { __numberBrand: any }; + var x : BrandedNum; + + // operator > + x > 0; + ~~~~~ +!!! error TS2365: Operator '>' cannot be applied to types 'BrandedNum' and '0'. + x > 0; + x > 0; + + // operator < + x < 0; + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types 'BrandedNum' and '0'. + x < 0; + x < 0; + + // operator >= + x >= 0; + ~~~~~~ +!!! error TS2365: Operator '>=' cannot be applied to types 'BrandedNum' and '0'. + x >= 0; + x >= 0; + + // operator <= + x <= 0; + ~~~~~~ +!!! error TS2365: Operator '<=' cannot be applied to types 'BrandedNum' and '0'. + x <= 0; + x <= 0; + + // operator == + x == 0; + x == 0; + x == 0; + + // operator != + x != 0; + x != 0; + x != 0; + + // operator === + x === 0; + x === 0; + x === 0; + + // operator !== + x !== 0; + x !== 0; + x !== 0; + \ No newline at end of file diff --git a/tests/baselines/reference/comparisonOperatorWithNumericLiteral.js b/tests/baselines/reference/comparisonOperatorWithNumericLiteral.js new file mode 100644 index 0000000000000..6f28423d16616 --- /dev/null +++ b/tests/baselines/reference/comparisonOperatorWithNumericLiteral.js @@ -0,0 +1,79 @@ +//// [comparisonOperatorWithNumericLiteral.ts] +type BrandedNum = number & { __numberBrand: any }; +var x : BrandedNum; + +// operator > +x > 0; +x > 0; +x > 0; + +// operator < +x < 0; +x < 0; +x < 0; + +// operator >= +x >= 0; +x >= 0; +x >= 0; + +// operator <= +x <= 0; +x <= 0; +x <= 0; + +// operator == +x == 0; +x == 0; +x == 0; + +// operator != +x != 0; +x != 0; +x != 0; + +// operator === +x === 0; +x === 0; +x === 0; + +// operator !== +x !== 0; +x !== 0; +x !== 0; + + +//// [comparisonOperatorWithNumericLiteral.js] +var x; +// operator > +x > 0; +x > 0; +x > 0; +// operator < +x < 0; +x < 0; +x < 0; +// operator >= +x >= 0; +x >= 0; +x >= 0; +// operator <= +x <= 0; +x <= 0; +x <= 0; +// operator == +x == 0; +x == 0; +x == 0; +// operator != +x != 0; +x != 0; +x != 0; +// operator === +x === 0; +x === 0; +x === 0; +// operator !== +x !== 0; +x !== 0; +x !== 0; diff --git a/tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNumericLiteral.ts b/tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNumericLiteral.ts new file mode 100644 index 0000000000000..457a324e97111 --- /dev/null +++ b/tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNumericLiteral.ts @@ -0,0 +1,42 @@ +type BrandedNum = number & { __numberBrand: any }; +var x : BrandedNum; + +// operator > +x > 0; +x > 0; +x > 0; + +// operator < +x < 0; +x < 0; +x < 0; + +// operator >= +x >= 0; +x >= 0; +x >= 0; + +// operator <= +x <= 0; +x <= 0; +x <= 0; + +// operator == +x == 0; +x == 0; +x == 0; + +// operator != +x != 0; +x != 0; +x != 0; + +// operator === +x === 0; +x === 0; +x === 0; + +// operator !== +x !== 0; +x !== 0; +x !== 0;