150 lines
7.9 KiB
Plaintext
150 lines
7.9 KiB
Plaintext
=== tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorWithIdenticalBCT.ts ===
|
|
//Cond ? Expr1 : Expr2, Expr1 and Expr2 have identical best common type
|
|
class X { propertyX: any; propertyX1: number; propertyX2: string };
|
|
>X : Symbol(X, Decl(conditionalOperatorWithIdenticalBCT.ts, 0, 0))
|
|
>propertyX : Symbol(propertyX, Decl(conditionalOperatorWithIdenticalBCT.ts, 1, 9))
|
|
>propertyX1 : Symbol(propertyX1, Decl(conditionalOperatorWithIdenticalBCT.ts, 1, 25))
|
|
>propertyX2 : Symbol(propertyX2, Decl(conditionalOperatorWithIdenticalBCT.ts, 1, 45))
|
|
|
|
class A extends X { propertyA: number };
|
|
>A : Symbol(A, Decl(conditionalOperatorWithIdenticalBCT.ts, 1, 67))
|
|
>X : Symbol(X, Decl(conditionalOperatorWithIdenticalBCT.ts, 0, 0))
|
|
>propertyA : Symbol(propertyA, Decl(conditionalOperatorWithIdenticalBCT.ts, 2, 19))
|
|
|
|
class B extends X { propertyB: string };
|
|
>B : Symbol(B, Decl(conditionalOperatorWithIdenticalBCT.ts, 2, 40))
|
|
>X : Symbol(X, Decl(conditionalOperatorWithIdenticalBCT.ts, 0, 0))
|
|
>propertyB : Symbol(propertyB, Decl(conditionalOperatorWithIdenticalBCT.ts, 3, 19))
|
|
|
|
var x: X;
|
|
>x : Symbol(x, Decl(conditionalOperatorWithIdenticalBCT.ts, 5, 3))
|
|
>X : Symbol(X, Decl(conditionalOperatorWithIdenticalBCT.ts, 0, 0))
|
|
|
|
var a: A;
|
|
>a : Symbol(a, Decl(conditionalOperatorWithIdenticalBCT.ts, 6, 3))
|
|
>A : Symbol(A, Decl(conditionalOperatorWithIdenticalBCT.ts, 1, 67))
|
|
|
|
var b: B;
|
|
>b : Symbol(b, Decl(conditionalOperatorWithIdenticalBCT.ts, 7, 3))
|
|
>B : Symbol(B, Decl(conditionalOperatorWithIdenticalBCT.ts, 2, 40))
|
|
|
|
//Cond ? Expr1 : Expr2, Expr1 is supertype
|
|
//Be Not contextually typed
|
|
true ? x : a;
|
|
>x : Symbol(x, Decl(conditionalOperatorWithIdenticalBCT.ts, 5, 3))
|
|
>a : Symbol(a, Decl(conditionalOperatorWithIdenticalBCT.ts, 6, 3))
|
|
|
|
var result1 = true ? x : a;
|
|
>result1 : Symbol(result1, Decl(conditionalOperatorWithIdenticalBCT.ts, 12, 3))
|
|
>x : Symbol(x, Decl(conditionalOperatorWithIdenticalBCT.ts, 5, 3))
|
|
>a : Symbol(a, Decl(conditionalOperatorWithIdenticalBCT.ts, 6, 3))
|
|
|
|
//Expr1 and Expr2 are literals
|
|
true ? {} : 1;
|
|
true ? { a: 1 } : { a: 2, b: 'string' };
|
|
>a : Symbol(a, Decl(conditionalOperatorWithIdenticalBCT.ts, 16, 8))
|
|
>a : Symbol(a, Decl(conditionalOperatorWithIdenticalBCT.ts, 16, 19))
|
|
>b : Symbol(b, Decl(conditionalOperatorWithIdenticalBCT.ts, 16, 25))
|
|
|
|
var result2 = true ? {} : 1;
|
|
>result2 : Symbol(result2, Decl(conditionalOperatorWithIdenticalBCT.ts, 17, 3))
|
|
|
|
var result3 = true ? { a: 1 } : { a: 2, b: 'string' };
|
|
>result3 : Symbol(result3, Decl(conditionalOperatorWithIdenticalBCT.ts, 18, 3))
|
|
>a : Symbol(a, Decl(conditionalOperatorWithIdenticalBCT.ts, 18, 22))
|
|
>a : Symbol(a, Decl(conditionalOperatorWithIdenticalBCT.ts, 18, 33))
|
|
>b : Symbol(b, Decl(conditionalOperatorWithIdenticalBCT.ts, 18, 39))
|
|
|
|
//Contextually typed
|
|
var resultIsX1: X = true ? x : a;
|
|
>resultIsX1 : Symbol(resultIsX1, Decl(conditionalOperatorWithIdenticalBCT.ts, 21, 3))
|
|
>X : Symbol(X, Decl(conditionalOperatorWithIdenticalBCT.ts, 0, 0))
|
|
>x : Symbol(x, Decl(conditionalOperatorWithIdenticalBCT.ts, 5, 3))
|
|
>a : Symbol(a, Decl(conditionalOperatorWithIdenticalBCT.ts, 6, 3))
|
|
|
|
var result4: (t: A) => any = true ? (m) => m.propertyX : (n) => n.propertyA;
|
|
>result4 : Symbol(result4, Decl(conditionalOperatorWithIdenticalBCT.ts, 22, 3))
|
|
>t : Symbol(t, Decl(conditionalOperatorWithIdenticalBCT.ts, 22, 14))
|
|
>A : Symbol(A, Decl(conditionalOperatorWithIdenticalBCT.ts, 1, 67))
|
|
>m : Symbol(m, Decl(conditionalOperatorWithIdenticalBCT.ts, 22, 37))
|
|
>m.propertyX : Symbol(X.propertyX, Decl(conditionalOperatorWithIdenticalBCT.ts, 1, 9))
|
|
>m : Symbol(m, Decl(conditionalOperatorWithIdenticalBCT.ts, 22, 37))
|
|
>propertyX : Symbol(X.propertyX, Decl(conditionalOperatorWithIdenticalBCT.ts, 1, 9))
|
|
>n : Symbol(n, Decl(conditionalOperatorWithIdenticalBCT.ts, 22, 58))
|
|
>n.propertyA : Symbol(A.propertyA, Decl(conditionalOperatorWithIdenticalBCT.ts, 2, 19))
|
|
>n : Symbol(n, Decl(conditionalOperatorWithIdenticalBCT.ts, 22, 58))
|
|
>propertyA : Symbol(A.propertyA, Decl(conditionalOperatorWithIdenticalBCT.ts, 2, 19))
|
|
|
|
//Cond ? Expr1 : Expr2, Expr2 is supertype
|
|
//Be Not contextually typed
|
|
true ? a : x;
|
|
>a : Symbol(a, Decl(conditionalOperatorWithIdenticalBCT.ts, 6, 3))
|
|
>x : Symbol(x, Decl(conditionalOperatorWithIdenticalBCT.ts, 5, 3))
|
|
|
|
var result5 = true ? a : x;
|
|
>result5 : Symbol(result5, Decl(conditionalOperatorWithIdenticalBCT.ts, 27, 3))
|
|
>a : Symbol(a, Decl(conditionalOperatorWithIdenticalBCT.ts, 6, 3))
|
|
>x : Symbol(x, Decl(conditionalOperatorWithIdenticalBCT.ts, 5, 3))
|
|
|
|
//Expr1 and Expr2 are literals
|
|
true ? 1 : {};
|
|
true ? { a: 2, b: 'string' } : { a: 1 };
|
|
>a : Symbol(a, Decl(conditionalOperatorWithIdenticalBCT.ts, 31, 8))
|
|
>b : Symbol(b, Decl(conditionalOperatorWithIdenticalBCT.ts, 31, 14))
|
|
>a : Symbol(a, Decl(conditionalOperatorWithIdenticalBCT.ts, 31, 32))
|
|
|
|
var result6 = true ? 1 : {};
|
|
>result6 : Symbol(result6, Decl(conditionalOperatorWithIdenticalBCT.ts, 32, 3))
|
|
|
|
var result7 = true ? { a: 2, b: 'string' } : { a: 1 };
|
|
>result7 : Symbol(result7, Decl(conditionalOperatorWithIdenticalBCT.ts, 33, 3))
|
|
>a : Symbol(a, Decl(conditionalOperatorWithIdenticalBCT.ts, 33, 22))
|
|
>b : Symbol(b, Decl(conditionalOperatorWithIdenticalBCT.ts, 33, 28))
|
|
>a : Symbol(a, Decl(conditionalOperatorWithIdenticalBCT.ts, 33, 46))
|
|
|
|
//Contextually typed
|
|
var resultIsX2: X = true ? x : a;
|
|
>resultIsX2 : Symbol(resultIsX2, Decl(conditionalOperatorWithIdenticalBCT.ts, 36, 3))
|
|
>X : Symbol(X, Decl(conditionalOperatorWithIdenticalBCT.ts, 0, 0))
|
|
>x : Symbol(x, Decl(conditionalOperatorWithIdenticalBCT.ts, 5, 3))
|
|
>a : Symbol(a, Decl(conditionalOperatorWithIdenticalBCT.ts, 6, 3))
|
|
|
|
var result8: (t: A) => any = true ? (m) => m.propertyA : (n) => n.propertyX;
|
|
>result8 : Symbol(result8, Decl(conditionalOperatorWithIdenticalBCT.ts, 37, 3))
|
|
>t : Symbol(t, Decl(conditionalOperatorWithIdenticalBCT.ts, 37, 14))
|
|
>A : Symbol(A, Decl(conditionalOperatorWithIdenticalBCT.ts, 1, 67))
|
|
>m : Symbol(m, Decl(conditionalOperatorWithIdenticalBCT.ts, 37, 37))
|
|
>m.propertyA : Symbol(A.propertyA, Decl(conditionalOperatorWithIdenticalBCT.ts, 2, 19))
|
|
>m : Symbol(m, Decl(conditionalOperatorWithIdenticalBCT.ts, 37, 37))
|
|
>propertyA : Symbol(A.propertyA, Decl(conditionalOperatorWithIdenticalBCT.ts, 2, 19))
|
|
>n : Symbol(n, Decl(conditionalOperatorWithIdenticalBCT.ts, 37, 58))
|
|
>n.propertyX : Symbol(X.propertyX, Decl(conditionalOperatorWithIdenticalBCT.ts, 1, 9))
|
|
>n : Symbol(n, Decl(conditionalOperatorWithIdenticalBCT.ts, 37, 58))
|
|
>propertyX : Symbol(X.propertyX, Decl(conditionalOperatorWithIdenticalBCT.ts, 1, 9))
|
|
|
|
//Result = Cond ? Expr1 : Expr2, Result is supertype
|
|
//Contextually typed
|
|
var resultIsX3: X = true ? a : b;
|
|
>resultIsX3 : Symbol(resultIsX3, Decl(conditionalOperatorWithIdenticalBCT.ts, 41, 3))
|
|
>X : Symbol(X, Decl(conditionalOperatorWithIdenticalBCT.ts, 0, 0))
|
|
>a : Symbol(a, Decl(conditionalOperatorWithIdenticalBCT.ts, 6, 3))
|
|
>b : Symbol(b, Decl(conditionalOperatorWithIdenticalBCT.ts, 7, 3))
|
|
|
|
var result10: (t: X) => any = true ? (m) => m.propertyX1 : (n) => n.propertyX2;
|
|
>result10 : Symbol(result10, Decl(conditionalOperatorWithIdenticalBCT.ts, 42, 3))
|
|
>t : Symbol(t, Decl(conditionalOperatorWithIdenticalBCT.ts, 42, 15))
|
|
>X : Symbol(X, Decl(conditionalOperatorWithIdenticalBCT.ts, 0, 0))
|
|
>m : Symbol(m, Decl(conditionalOperatorWithIdenticalBCT.ts, 42, 38))
|
|
>m.propertyX1 : Symbol(X.propertyX1, Decl(conditionalOperatorWithIdenticalBCT.ts, 1, 25))
|
|
>m : Symbol(m, Decl(conditionalOperatorWithIdenticalBCT.ts, 42, 38))
|
|
>propertyX1 : Symbol(X.propertyX1, Decl(conditionalOperatorWithIdenticalBCT.ts, 1, 25))
|
|
>n : Symbol(n, Decl(conditionalOperatorWithIdenticalBCT.ts, 42, 60))
|
|
>n.propertyX2 : Symbol(X.propertyX2, Decl(conditionalOperatorWithIdenticalBCT.ts, 1, 45))
|
|
>n : Symbol(n, Decl(conditionalOperatorWithIdenticalBCT.ts, 42, 60))
|
|
>propertyX2 : Symbol(X.propertyX2, Decl(conditionalOperatorWithIdenticalBCT.ts, 1, 45))
|
|
|
|
//Expr1 and Expr2 are literals
|
|
var result11: any = true ? 1 : 'string';
|
|
>result11 : Symbol(result11, Decl(conditionalOperatorWithIdenticalBCT.ts, 45, 3))
|
|
|