245 lines
15 KiB
Text
245 lines
15 KiB
Text
=== tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorConditoinIsStringType.ts ===
|
|
//Cond ? Expr1 : Expr2, Cond is of string type, Expr1 and Expr2 have the same type
|
|
var condString: string;
|
|
>condString : Symbol(condString, Decl(conditionalOperatorConditoinIsStringType.ts, 1, 3))
|
|
|
|
var exprAny1: any;
|
|
>exprAny1 : Symbol(exprAny1, Decl(conditionalOperatorConditoinIsStringType.ts, 3, 3))
|
|
|
|
var exprBoolean1: boolean;
|
|
>exprBoolean1 : Symbol(exprBoolean1, Decl(conditionalOperatorConditoinIsStringType.ts, 4, 3))
|
|
|
|
var exprNumber1: number;
|
|
>exprNumber1 : Symbol(exprNumber1, Decl(conditionalOperatorConditoinIsStringType.ts, 5, 3))
|
|
|
|
var exprString1: string;
|
|
>exprString1 : Symbol(exprString1, Decl(conditionalOperatorConditoinIsStringType.ts, 6, 3))
|
|
|
|
var exprIsObject1: Object;
|
|
>exprIsObject1 : Symbol(exprIsObject1, Decl(conditionalOperatorConditoinIsStringType.ts, 7, 3))
|
|
>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11))
|
|
|
|
var exprAny2: any;
|
|
>exprAny2 : Symbol(exprAny2, Decl(conditionalOperatorConditoinIsStringType.ts, 9, 3))
|
|
|
|
var exprBoolean2: boolean;
|
|
>exprBoolean2 : Symbol(exprBoolean2, Decl(conditionalOperatorConditoinIsStringType.ts, 10, 3))
|
|
|
|
var exprNumber2: number;
|
|
>exprNumber2 : Symbol(exprNumber2, Decl(conditionalOperatorConditoinIsStringType.ts, 11, 3))
|
|
|
|
var exprString2: string;
|
|
>exprString2 : Symbol(exprString2, Decl(conditionalOperatorConditoinIsStringType.ts, 12, 3))
|
|
|
|
var exprIsObject2: Object;
|
|
>exprIsObject2 : Symbol(exprIsObject2, Decl(conditionalOperatorConditoinIsStringType.ts, 13, 3))
|
|
>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11))
|
|
|
|
//Cond is a string type variable
|
|
condString ? exprAny1 : exprAny2;
|
|
>condString : Symbol(condString, Decl(conditionalOperatorConditoinIsStringType.ts, 1, 3))
|
|
>exprAny1 : Symbol(exprAny1, Decl(conditionalOperatorConditoinIsStringType.ts, 3, 3))
|
|
>exprAny2 : Symbol(exprAny2, Decl(conditionalOperatorConditoinIsStringType.ts, 9, 3))
|
|
|
|
condString ? exprBoolean1 : exprBoolean2;
|
|
>condString : Symbol(condString, Decl(conditionalOperatorConditoinIsStringType.ts, 1, 3))
|
|
>exprBoolean1 : Symbol(exprBoolean1, Decl(conditionalOperatorConditoinIsStringType.ts, 4, 3))
|
|
>exprBoolean2 : Symbol(exprBoolean2, Decl(conditionalOperatorConditoinIsStringType.ts, 10, 3))
|
|
|
|
condString ? exprNumber1 : exprNumber2;
|
|
>condString : Symbol(condString, Decl(conditionalOperatorConditoinIsStringType.ts, 1, 3))
|
|
>exprNumber1 : Symbol(exprNumber1, Decl(conditionalOperatorConditoinIsStringType.ts, 5, 3))
|
|
>exprNumber2 : Symbol(exprNumber2, Decl(conditionalOperatorConditoinIsStringType.ts, 11, 3))
|
|
|
|
condString ? exprString1 : exprString2;
|
|
>condString : Symbol(condString, Decl(conditionalOperatorConditoinIsStringType.ts, 1, 3))
|
|
>exprString1 : Symbol(exprString1, Decl(conditionalOperatorConditoinIsStringType.ts, 6, 3))
|
|
>exprString2 : Symbol(exprString2, Decl(conditionalOperatorConditoinIsStringType.ts, 12, 3))
|
|
|
|
condString ? exprIsObject1 : exprIsObject2;
|
|
>condString : Symbol(condString, Decl(conditionalOperatorConditoinIsStringType.ts, 1, 3))
|
|
>exprIsObject1 : Symbol(exprIsObject1, Decl(conditionalOperatorConditoinIsStringType.ts, 7, 3))
|
|
>exprIsObject2 : Symbol(exprIsObject2, Decl(conditionalOperatorConditoinIsStringType.ts, 13, 3))
|
|
|
|
condString ? exprString1 : exprBoolean1; // union
|
|
>condString : Symbol(condString, Decl(conditionalOperatorConditoinIsStringType.ts, 1, 3))
|
|
>exprString1 : Symbol(exprString1, Decl(conditionalOperatorConditoinIsStringType.ts, 6, 3))
|
|
>exprBoolean1 : Symbol(exprBoolean1, Decl(conditionalOperatorConditoinIsStringType.ts, 4, 3))
|
|
|
|
//Cond is a string type literal
|
|
"" ? exprAny1 : exprAny2;
|
|
>exprAny1 : Symbol(exprAny1, Decl(conditionalOperatorConditoinIsStringType.ts, 3, 3))
|
|
>exprAny2 : Symbol(exprAny2, Decl(conditionalOperatorConditoinIsStringType.ts, 9, 3))
|
|
|
|
"string" ? exprBoolean1 : exprBoolean2;
|
|
>exprBoolean1 : Symbol(exprBoolean1, Decl(conditionalOperatorConditoinIsStringType.ts, 4, 3))
|
|
>exprBoolean2 : Symbol(exprBoolean2, Decl(conditionalOperatorConditoinIsStringType.ts, 10, 3))
|
|
|
|
'c' ? exprNumber1 : exprNumber2;
|
|
>exprNumber1 : Symbol(exprNumber1, Decl(conditionalOperatorConditoinIsStringType.ts, 5, 3))
|
|
>exprNumber2 : Symbol(exprNumber2, Decl(conditionalOperatorConditoinIsStringType.ts, 11, 3))
|
|
|
|
'string' ? exprString1 : exprString2;
|
|
>exprString1 : Symbol(exprString1, Decl(conditionalOperatorConditoinIsStringType.ts, 6, 3))
|
|
>exprString2 : Symbol(exprString2, Decl(conditionalOperatorConditoinIsStringType.ts, 12, 3))
|
|
|
|
" " ? exprIsObject1 : exprIsObject2;
|
|
>exprIsObject1 : Symbol(exprIsObject1, Decl(conditionalOperatorConditoinIsStringType.ts, 7, 3))
|
|
>exprIsObject2 : Symbol(exprIsObject2, Decl(conditionalOperatorConditoinIsStringType.ts, 13, 3))
|
|
|
|
"hello " ? exprString1 : exprBoolean1; // union
|
|
>exprString1 : Symbol(exprString1, Decl(conditionalOperatorConditoinIsStringType.ts, 6, 3))
|
|
>exprBoolean1 : Symbol(exprBoolean1, Decl(conditionalOperatorConditoinIsStringType.ts, 4, 3))
|
|
|
|
//Cond is a string type expression
|
|
function foo() { return "string" };
|
|
>foo : Symbol(foo, Decl(conditionalOperatorConditoinIsStringType.ts, 29, 38))
|
|
|
|
var array = ["1", "2", "3"];
|
|
>array : Symbol(array, Decl(conditionalOperatorConditoinIsStringType.ts, 33, 3))
|
|
|
|
typeof condString ? exprAny1 : exprAny2;
|
|
>condString : Symbol(condString, Decl(conditionalOperatorConditoinIsStringType.ts, 1, 3))
|
|
>exprAny1 : Symbol(exprAny1, Decl(conditionalOperatorConditoinIsStringType.ts, 3, 3))
|
|
>exprAny2 : Symbol(exprAny2, Decl(conditionalOperatorConditoinIsStringType.ts, 9, 3))
|
|
|
|
condString.toUpperCase ? exprBoolean1 : exprBoolean2;
|
|
>condString.toUpperCase : Symbol(String.toUpperCase, Decl(lib.d.ts, 405, 32))
|
|
>condString : Symbol(condString, Decl(conditionalOperatorConditoinIsStringType.ts, 1, 3))
|
|
>toUpperCase : Symbol(String.toUpperCase, Decl(lib.d.ts, 405, 32))
|
|
>exprBoolean1 : Symbol(exprBoolean1, Decl(conditionalOperatorConditoinIsStringType.ts, 4, 3))
|
|
>exprBoolean2 : Symbol(exprBoolean2, Decl(conditionalOperatorConditoinIsStringType.ts, 10, 3))
|
|
|
|
condString + "string" ? exprNumber1 : exprNumber2;
|
|
>condString : Symbol(condString, Decl(conditionalOperatorConditoinIsStringType.ts, 1, 3))
|
|
>exprNumber1 : Symbol(exprNumber1, Decl(conditionalOperatorConditoinIsStringType.ts, 5, 3))
|
|
>exprNumber2 : Symbol(exprNumber2, Decl(conditionalOperatorConditoinIsStringType.ts, 11, 3))
|
|
|
|
foo() ? exprString1 : exprString2;
|
|
>foo : Symbol(foo, Decl(conditionalOperatorConditoinIsStringType.ts, 29, 38))
|
|
>exprString1 : Symbol(exprString1, Decl(conditionalOperatorConditoinIsStringType.ts, 6, 3))
|
|
>exprString2 : Symbol(exprString2, Decl(conditionalOperatorConditoinIsStringType.ts, 12, 3))
|
|
|
|
array[1] ? exprIsObject1 : exprIsObject2;
|
|
>array : Symbol(array, Decl(conditionalOperatorConditoinIsStringType.ts, 33, 3))
|
|
>exprIsObject1 : Symbol(exprIsObject1, Decl(conditionalOperatorConditoinIsStringType.ts, 7, 3))
|
|
>exprIsObject2 : Symbol(exprIsObject2, Decl(conditionalOperatorConditoinIsStringType.ts, 13, 3))
|
|
|
|
foo() ? exprString1 : exprBoolean1; // union
|
|
>foo : Symbol(foo, Decl(conditionalOperatorConditoinIsStringType.ts, 29, 38))
|
|
>exprString1 : Symbol(exprString1, Decl(conditionalOperatorConditoinIsStringType.ts, 6, 3))
|
|
>exprBoolean1 : Symbol(exprBoolean1, Decl(conditionalOperatorConditoinIsStringType.ts, 4, 3))
|
|
|
|
//Results shoud be same as Expr1 and Expr2
|
|
var resultIsAny1 = condString ? exprAny1 : exprAny2;
|
|
>resultIsAny1 : Symbol(resultIsAny1, Decl(conditionalOperatorConditoinIsStringType.ts, 43, 3))
|
|
>condString : Symbol(condString, Decl(conditionalOperatorConditoinIsStringType.ts, 1, 3))
|
|
>exprAny1 : Symbol(exprAny1, Decl(conditionalOperatorConditoinIsStringType.ts, 3, 3))
|
|
>exprAny2 : Symbol(exprAny2, Decl(conditionalOperatorConditoinIsStringType.ts, 9, 3))
|
|
|
|
var resultIsBoolean1 = condString ? exprBoolean1 : exprBoolean2;
|
|
>resultIsBoolean1 : Symbol(resultIsBoolean1, Decl(conditionalOperatorConditoinIsStringType.ts, 44, 3))
|
|
>condString : Symbol(condString, Decl(conditionalOperatorConditoinIsStringType.ts, 1, 3))
|
|
>exprBoolean1 : Symbol(exprBoolean1, Decl(conditionalOperatorConditoinIsStringType.ts, 4, 3))
|
|
>exprBoolean2 : Symbol(exprBoolean2, Decl(conditionalOperatorConditoinIsStringType.ts, 10, 3))
|
|
|
|
var resultIsNumber1 = condString ? exprNumber1 : exprNumber2;
|
|
>resultIsNumber1 : Symbol(resultIsNumber1, Decl(conditionalOperatorConditoinIsStringType.ts, 45, 3))
|
|
>condString : Symbol(condString, Decl(conditionalOperatorConditoinIsStringType.ts, 1, 3))
|
|
>exprNumber1 : Symbol(exprNumber1, Decl(conditionalOperatorConditoinIsStringType.ts, 5, 3))
|
|
>exprNumber2 : Symbol(exprNumber2, Decl(conditionalOperatorConditoinIsStringType.ts, 11, 3))
|
|
|
|
var resultIsString1 = condString ? exprString1 : exprString2;
|
|
>resultIsString1 : Symbol(resultIsString1, Decl(conditionalOperatorConditoinIsStringType.ts, 46, 3))
|
|
>condString : Symbol(condString, Decl(conditionalOperatorConditoinIsStringType.ts, 1, 3))
|
|
>exprString1 : Symbol(exprString1, Decl(conditionalOperatorConditoinIsStringType.ts, 6, 3))
|
|
>exprString2 : Symbol(exprString2, Decl(conditionalOperatorConditoinIsStringType.ts, 12, 3))
|
|
|
|
var resultIsObject1 = condString ? exprIsObject1 : exprIsObject2;
|
|
>resultIsObject1 : Symbol(resultIsObject1, Decl(conditionalOperatorConditoinIsStringType.ts, 47, 3))
|
|
>condString : Symbol(condString, Decl(conditionalOperatorConditoinIsStringType.ts, 1, 3))
|
|
>exprIsObject1 : Symbol(exprIsObject1, Decl(conditionalOperatorConditoinIsStringType.ts, 7, 3))
|
|
>exprIsObject2 : Symbol(exprIsObject2, Decl(conditionalOperatorConditoinIsStringType.ts, 13, 3))
|
|
|
|
var resultIsStringOrBoolean1 = condString ? exprString1 : exprBoolean1; // union
|
|
>resultIsStringOrBoolean1 : Symbol(resultIsStringOrBoolean1, Decl(conditionalOperatorConditoinIsStringType.ts, 48, 3))
|
|
>condString : Symbol(condString, Decl(conditionalOperatorConditoinIsStringType.ts, 1, 3))
|
|
>exprString1 : Symbol(exprString1, Decl(conditionalOperatorConditoinIsStringType.ts, 6, 3))
|
|
>exprBoolean1 : Symbol(exprBoolean1, Decl(conditionalOperatorConditoinIsStringType.ts, 4, 3))
|
|
|
|
var resultIsAny2 = "" ? exprAny1 : exprAny2;
|
|
>resultIsAny2 : Symbol(resultIsAny2, Decl(conditionalOperatorConditoinIsStringType.ts, 50, 3))
|
|
>exprAny1 : Symbol(exprAny1, Decl(conditionalOperatorConditoinIsStringType.ts, 3, 3))
|
|
>exprAny2 : Symbol(exprAny2, Decl(conditionalOperatorConditoinIsStringType.ts, 9, 3))
|
|
|
|
var resultIsBoolean2 = "string" ? exprBoolean1 : exprBoolean2;
|
|
>resultIsBoolean2 : Symbol(resultIsBoolean2, Decl(conditionalOperatorConditoinIsStringType.ts, 51, 3))
|
|
>exprBoolean1 : Symbol(exprBoolean1, Decl(conditionalOperatorConditoinIsStringType.ts, 4, 3))
|
|
>exprBoolean2 : Symbol(exprBoolean2, Decl(conditionalOperatorConditoinIsStringType.ts, 10, 3))
|
|
|
|
var resultIsNumber2 = 'c' ? exprNumber1 : exprNumber2;
|
|
>resultIsNumber2 : Symbol(resultIsNumber2, Decl(conditionalOperatorConditoinIsStringType.ts, 52, 3))
|
|
>exprNumber1 : Symbol(exprNumber1, Decl(conditionalOperatorConditoinIsStringType.ts, 5, 3))
|
|
>exprNumber2 : Symbol(exprNumber2, Decl(conditionalOperatorConditoinIsStringType.ts, 11, 3))
|
|
|
|
var resultIsString2 = 'string' ? exprString1 : exprString2;
|
|
>resultIsString2 : Symbol(resultIsString2, Decl(conditionalOperatorConditoinIsStringType.ts, 53, 3))
|
|
>exprString1 : Symbol(exprString1, Decl(conditionalOperatorConditoinIsStringType.ts, 6, 3))
|
|
>exprString2 : Symbol(exprString2, Decl(conditionalOperatorConditoinIsStringType.ts, 12, 3))
|
|
|
|
var resultIsObject2 = " " ? exprIsObject1 : exprIsObject2;
|
|
>resultIsObject2 : Symbol(resultIsObject2, Decl(conditionalOperatorConditoinIsStringType.ts, 54, 3))
|
|
>exprIsObject1 : Symbol(exprIsObject1, Decl(conditionalOperatorConditoinIsStringType.ts, 7, 3))
|
|
>exprIsObject2 : Symbol(exprIsObject2, Decl(conditionalOperatorConditoinIsStringType.ts, 13, 3))
|
|
|
|
var resultIsStringOrBoolean2 = "hello" ? exprString1 : exprBoolean1; // union
|
|
>resultIsStringOrBoolean2 : Symbol(resultIsStringOrBoolean2, Decl(conditionalOperatorConditoinIsStringType.ts, 55, 3))
|
|
>exprString1 : Symbol(exprString1, Decl(conditionalOperatorConditoinIsStringType.ts, 6, 3))
|
|
>exprBoolean1 : Symbol(exprBoolean1, Decl(conditionalOperatorConditoinIsStringType.ts, 4, 3))
|
|
|
|
var resultIsAny3 = typeof condString ? exprAny1 : exprAny2;
|
|
>resultIsAny3 : Symbol(resultIsAny3, Decl(conditionalOperatorConditoinIsStringType.ts, 57, 3))
|
|
>condString : Symbol(condString, Decl(conditionalOperatorConditoinIsStringType.ts, 1, 3))
|
|
>exprAny1 : Symbol(exprAny1, Decl(conditionalOperatorConditoinIsStringType.ts, 3, 3))
|
|
>exprAny2 : Symbol(exprAny2, Decl(conditionalOperatorConditoinIsStringType.ts, 9, 3))
|
|
|
|
var resultIsBoolean3 = condString.toUpperCase ? exprBoolean1 : exprBoolean2;
|
|
>resultIsBoolean3 : Symbol(resultIsBoolean3, Decl(conditionalOperatorConditoinIsStringType.ts, 58, 3))
|
|
>condString.toUpperCase : Symbol(String.toUpperCase, Decl(lib.d.ts, 405, 32))
|
|
>condString : Symbol(condString, Decl(conditionalOperatorConditoinIsStringType.ts, 1, 3))
|
|
>toUpperCase : Symbol(String.toUpperCase, Decl(lib.d.ts, 405, 32))
|
|
>exprBoolean1 : Symbol(exprBoolean1, Decl(conditionalOperatorConditoinIsStringType.ts, 4, 3))
|
|
>exprBoolean2 : Symbol(exprBoolean2, Decl(conditionalOperatorConditoinIsStringType.ts, 10, 3))
|
|
|
|
var resultIsNumber3 = condString + "string" ? exprNumber1 : exprNumber2;
|
|
>resultIsNumber3 : Symbol(resultIsNumber3, Decl(conditionalOperatorConditoinIsStringType.ts, 59, 3))
|
|
>condString : Symbol(condString, Decl(conditionalOperatorConditoinIsStringType.ts, 1, 3))
|
|
>exprNumber1 : Symbol(exprNumber1, Decl(conditionalOperatorConditoinIsStringType.ts, 5, 3))
|
|
>exprNumber2 : Symbol(exprNumber2, Decl(conditionalOperatorConditoinIsStringType.ts, 11, 3))
|
|
|
|
var resultIsString3 = foo() ? exprString1 : exprString2;
|
|
>resultIsString3 : Symbol(resultIsString3, Decl(conditionalOperatorConditoinIsStringType.ts, 60, 3))
|
|
>foo : Symbol(foo, Decl(conditionalOperatorConditoinIsStringType.ts, 29, 38))
|
|
>exprString1 : Symbol(exprString1, Decl(conditionalOperatorConditoinIsStringType.ts, 6, 3))
|
|
>exprString2 : Symbol(exprString2, Decl(conditionalOperatorConditoinIsStringType.ts, 12, 3))
|
|
|
|
var resultIsObject3 = array[1] ? exprIsObject1 : exprIsObject2;
|
|
>resultIsObject3 : Symbol(resultIsObject3, Decl(conditionalOperatorConditoinIsStringType.ts, 61, 3))
|
|
>array : Symbol(array, Decl(conditionalOperatorConditoinIsStringType.ts, 33, 3))
|
|
>exprIsObject1 : Symbol(exprIsObject1, Decl(conditionalOperatorConditoinIsStringType.ts, 7, 3))
|
|
>exprIsObject2 : Symbol(exprIsObject2, Decl(conditionalOperatorConditoinIsStringType.ts, 13, 3))
|
|
|
|
var resultIsStringOrBoolean3 = typeof condString ? exprString1 : exprBoolean1; // union
|
|
>resultIsStringOrBoolean3 : Symbol(resultIsStringOrBoolean3, Decl(conditionalOperatorConditoinIsStringType.ts, 62, 3))
|
|
>condString : Symbol(condString, Decl(conditionalOperatorConditoinIsStringType.ts, 1, 3))
|
|
>exprString1 : Symbol(exprString1, Decl(conditionalOperatorConditoinIsStringType.ts, 6, 3))
|
|
>exprBoolean1 : Symbol(exprBoolean1, Decl(conditionalOperatorConditoinIsStringType.ts, 4, 3))
|
|
|
|
var resultIsStringOrBoolean4 = condString.toUpperCase ? exprString1 : exprBoolean1; // union
|
|
>resultIsStringOrBoolean4 : Symbol(resultIsStringOrBoolean4, Decl(conditionalOperatorConditoinIsStringType.ts, 63, 3))
|
|
>condString.toUpperCase : Symbol(String.toUpperCase, Decl(lib.d.ts, 405, 32))
|
|
>condString : Symbol(condString, Decl(conditionalOperatorConditoinIsStringType.ts, 1, 3))
|
|
>toUpperCase : Symbol(String.toUpperCase, Decl(lib.d.ts, 405, 32))
|
|
>exprString1 : Symbol(exprString1, Decl(conditionalOperatorConditoinIsStringType.ts, 6, 3))
|
|
>exprBoolean1 : Symbol(exprBoolean1, Decl(conditionalOperatorConditoinIsStringType.ts, 4, 3))
|
|
|