mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-07 05:41:22 -06:00
fix(45489): add test to cover comparison operator with intersection type (#45936)
This commit is contained in:
parent
ec114b8931
commit
15a46bb72d
@ -0,0 +1,15 @@
|
||||
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIntersectionType.ts(2,1): error TS2365: Operator '>' cannot be applied to types '{ a: 1; }' and 'number'.
|
||||
tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIntersectionType.ts(5,1): error TS2365: Operator '>' cannot be applied to types '{ a: 1; } & { b: number; }' and 'number'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIntersectionType.ts (2 errors) ====
|
||||
declare let a: { a: 1 }
|
||||
a > 1;
|
||||
~~~~~
|
||||
!!! error TS2365: Operator '>' cannot be applied to types '{ a: 1; }' and 'number'.
|
||||
|
||||
declare let b: { a: 1 } & { b: number }
|
||||
b > 1;
|
||||
~~~~~
|
||||
!!! error TS2365: Operator '>' cannot be applied to types '{ a: 1; } & { b: number; }' and 'number'.
|
||||
|
||||
@ -0,0 +1,11 @@
|
||||
//// [comparisonOperatorWithIntersectionType.ts]
|
||||
declare let a: { a: 1 }
|
||||
a > 1;
|
||||
|
||||
declare let b: { a: 1 } & { b: number }
|
||||
b > 1;
|
||||
|
||||
|
||||
//// [comparisonOperatorWithIntersectionType.js]
|
||||
a > 1;
|
||||
b > 1;
|
||||
@ -0,0 +1,16 @@
|
||||
=== tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIntersectionType.ts ===
|
||||
declare let a: { a: 1 }
|
||||
>a : Symbol(a, Decl(comparisonOperatorWithIntersectionType.ts, 0, 11))
|
||||
>a : Symbol(a, Decl(comparisonOperatorWithIntersectionType.ts, 0, 16))
|
||||
|
||||
a > 1;
|
||||
>a : Symbol(a, Decl(comparisonOperatorWithIntersectionType.ts, 0, 11))
|
||||
|
||||
declare let b: { a: 1 } & { b: number }
|
||||
>b : Symbol(b, Decl(comparisonOperatorWithIntersectionType.ts, 3, 11))
|
||||
>a : Symbol(a, Decl(comparisonOperatorWithIntersectionType.ts, 3, 16))
|
||||
>b : Symbol(b, Decl(comparisonOperatorWithIntersectionType.ts, 3, 27))
|
||||
|
||||
b > 1;
|
||||
>b : Symbol(b, Decl(comparisonOperatorWithIntersectionType.ts, 3, 11))
|
||||
|
||||
@ -0,0 +1,20 @@
|
||||
=== tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIntersectionType.ts ===
|
||||
declare let a: { a: 1 }
|
||||
>a : { a: 1; }
|
||||
>a : 1
|
||||
|
||||
a > 1;
|
||||
>a > 1 : boolean
|
||||
>a : { a: 1; }
|
||||
>1 : 1
|
||||
|
||||
declare let b: { a: 1 } & { b: number }
|
||||
>b : { a: 1; } & { b: number; }
|
||||
>a : 1
|
||||
>b : number
|
||||
|
||||
b > 1;
|
||||
>b > 1 : boolean
|
||||
>b : { a: 1; } & { b: number; }
|
||||
>1 : 1
|
||||
|
||||
@ -0,0 +1,5 @@
|
||||
declare let a: { a: 1 }
|
||||
a > 1;
|
||||
|
||||
declare let b: { a: 1 } & { b: number }
|
||||
b > 1;
|
||||
Loading…
x
Reference in New Issue
Block a user