297 lines
8.6 KiB
Text
297 lines
8.6 KiB
Text
|
=== tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorConditionIsObjectType.ts ===
|
||
|
//Cond ? Expr1 : Expr2, Cond is of object type, Expr1 and Expr2 have the same type
|
||
|
var condObject: Object;
|
||
|
>condObject : Object
|
||
|
>Object : Object
|
||
|
|
||
|
var exprAny1: any;
|
||
|
>exprAny1 : any
|
||
|
|
||
|
var exprBoolean1: boolean;
|
||
|
>exprBoolean1 : boolean
|
||
|
|
||
|
var exprNumber1: number;
|
||
|
>exprNumber1 : number
|
||
|
|
||
|
var exprString1: string;
|
||
|
>exprString1 : string
|
||
|
|
||
|
var exprIsObject1: Object;
|
||
|
>exprIsObject1 : Object
|
||
|
>Object : Object
|
||
|
|
||
|
var exprAny2: any;
|
||
|
>exprAny2 : any
|
||
|
|
||
|
var exprBoolean2: boolean;
|
||
|
>exprBoolean2 : boolean
|
||
|
|
||
|
var exprNumber2: number;
|
||
|
>exprNumber2 : number
|
||
|
|
||
|
var exprString2: string;
|
||
|
>exprString2 : string
|
||
|
|
||
|
var exprIsObject2: Object;
|
||
|
>exprIsObject2 : Object
|
||
|
>Object : Object
|
||
|
|
||
|
function foo() { };
|
||
|
>foo : () => void
|
||
|
|
||
|
class C { static doIt: () => void };
|
||
|
>C : C
|
||
|
>doIt : () => void
|
||
|
|
||
|
//Cond is an object type variable
|
||
|
condObject ? exprAny1 : exprAny2;
|
||
|
>condObject ? exprAny1 : exprAny2 : any
|
||
|
>condObject : Object
|
||
|
>exprAny1 : any
|
||
|
>exprAny2 : any
|
||
|
|
||
|
condObject ? exprBoolean1 : exprBoolean2;
|
||
|
>condObject ? exprBoolean1 : exprBoolean2 : boolean
|
||
|
>condObject : Object
|
||
|
>exprBoolean1 : boolean
|
||
|
>exprBoolean2 : boolean
|
||
|
|
||
|
condObject ? exprNumber1 : exprNumber2;
|
||
|
>condObject ? exprNumber1 : exprNumber2 : number
|
||
|
>condObject : Object
|
||
|
>exprNumber1 : number
|
||
|
>exprNumber2 : number
|
||
|
|
||
|
condObject ? exprString1 : exprString2;
|
||
|
>condObject ? exprString1 : exprString2 : string
|
||
|
>condObject : Object
|
||
|
>exprString1 : string
|
||
|
>exprString2 : string
|
||
|
|
||
|
condObject ? exprIsObject1 : exprIsObject2;
|
||
|
>condObject ? exprIsObject1 : exprIsObject2 : Object
|
||
|
>condObject : Object
|
||
|
>exprIsObject1 : Object
|
||
|
>exprIsObject2 : Object
|
||
|
|
||
|
//Cond is an object type literal
|
||
|
((a: string) => a.length) ? exprAny1 : exprAny2;
|
||
|
>((a: string) => a.length) ? exprAny1 : exprAny2 : any
|
||
|
>((a: string) => a.length) : (a: string) => number
|
||
|
>(a: string) => a.length : (a: string) => number
|
||
|
>a : string
|
||
|
>a.length : number
|
||
|
>a : string
|
||
|
>length : number
|
||
|
>exprAny1 : any
|
||
|
>exprAny2 : any
|
||
|
|
||
|
((a: string) => a.length) ? exprBoolean1 : exprBoolean2;
|
||
|
>((a: string) => a.length) ? exprBoolean1 : exprBoolean2 : boolean
|
||
|
>((a: string) => a.length) : (a: string) => number
|
||
|
>(a: string) => a.length : (a: string) => number
|
||
|
>a : string
|
||
|
>a.length : number
|
||
|
>a : string
|
||
|
>length : number
|
||
|
>exprBoolean1 : boolean
|
||
|
>exprBoolean2 : boolean
|
||
|
|
||
|
({}) ? exprNumber1 : exprNumber2;
|
||
|
>({}) ? exprNumber1 : exprNumber2 : number
|
||
|
>({}) : {}
|
||
|
>{} : {}
|
||
|
>exprNumber1 : number
|
||
|
>exprNumber2 : number
|
||
|
|
||
|
({ a: 1, b: "s" }) ? exprString1 : exprString2;
|
||
|
>({ a: 1, b: "s" }) ? exprString1 : exprString2 : string
|
||
|
>({ a: 1, b: "s" }) : { a: number; b: string; }
|
||
|
>{ a: 1, b: "s" } : { a: number; b: string; }
|
||
|
>a : number
|
||
|
>b : string
|
||
|
>exprString1 : string
|
||
|
>exprString2 : string
|
||
|
|
||
|
({ a: 1, b: "s" }) ? exprIsObject1 : exprIsObject2;
|
||
|
>({ a: 1, b: "s" }) ? exprIsObject1 : exprIsObject2 : Object
|
||
|
>({ a: 1, b: "s" }) : { a: number; b: string; }
|
||
|
>{ a: 1, b: "s" } : { a: number; b: string; }
|
||
|
>a : number
|
||
|
>b : string
|
||
|
>exprIsObject1 : Object
|
||
|
>exprIsObject2 : Object
|
||
|
|
||
|
//Cond is an object type expression
|
||
|
foo() ? exprAny1 : exprAny2;
|
||
|
>foo() ? exprAny1 : exprAny2 : any
|
||
|
>foo() : void
|
||
|
>foo : () => void
|
||
|
>exprAny1 : any
|
||
|
>exprAny2 : any
|
||
|
|
||
|
new Date() ? exprBoolean1 : exprBoolean2;
|
||
|
>new Date() ? exprBoolean1 : exprBoolean2 : boolean
|
||
|
>new Date() : Date
|
||
|
>Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; }
|
||
|
>exprBoolean1 : boolean
|
||
|
>exprBoolean2 : boolean
|
||
|
|
||
|
new C() ? exprNumber1 : exprNumber2;
|
||
|
>new C() ? exprNumber1 : exprNumber2 : number
|
||
|
>new C() : C
|
||
|
>C : typeof C
|
||
|
>exprNumber1 : number
|
||
|
>exprNumber2 : number
|
||
|
|
||
|
C.doIt() ? exprString1 : exprString2;
|
||
|
>C.doIt() ? exprString1 : exprString2 : string
|
||
|
>C.doIt() : void
|
||
|
>C.doIt : () => void
|
||
|
>C : typeof C
|
||
|
>doIt : () => void
|
||
|
>exprString1 : string
|
||
|
>exprString2 : string
|
||
|
|
||
|
condObject.valueOf() ? exprIsObject1 : exprIsObject2;
|
||
|
>condObject.valueOf() ? exprIsObject1 : exprIsObject2 : Object
|
||
|
>condObject.valueOf() : Object
|
||
|
>condObject.valueOf : () => Object
|
||
|
>condObject : Object
|
||
|
>valueOf : () => Object
|
||
|
>exprIsObject1 : Object
|
||
|
>exprIsObject2 : Object
|
||
|
|
||
|
//Results shoud be same as Expr1 and Expr2
|
||
|
var resultIsAny1 = condObject ? exprAny1 : exprAny2;
|
||
|
>resultIsAny1 : any
|
||
|
>condObject ? exprAny1 : exprAny2 : any
|
||
|
>condObject : Object
|
||
|
>exprAny1 : any
|
||
|
>exprAny2 : any
|
||
|
|
||
|
var resultIsBoolean1 = condObject ? exprBoolean1 : exprBoolean2;
|
||
|
>resultIsBoolean1 : boolean
|
||
|
>condObject ? exprBoolean1 : exprBoolean2 : boolean
|
||
|
>condObject : Object
|
||
|
>exprBoolean1 : boolean
|
||
|
>exprBoolean2 : boolean
|
||
|
|
||
|
var resultIsNumber1 = condObject ? exprNumber1 : exprNumber2;
|
||
|
>resultIsNumber1 : number
|
||
|
>condObject ? exprNumber1 : exprNumber2 : number
|
||
|
>condObject : Object
|
||
|
>exprNumber1 : number
|
||
|
>exprNumber2 : number
|
||
|
|
||
|
var resultIsString1 = condObject ? exprString1 : exprString2;
|
||
|
>resultIsString1 : string
|
||
|
>condObject ? exprString1 : exprString2 : string
|
||
|
>condObject : Object
|
||
|
>exprString1 : string
|
||
|
>exprString2 : string
|
||
|
|
||
|
var resultIsObject1 = condObject ? exprIsObject1 : exprIsObject2;
|
||
|
>resultIsObject1 : Object
|
||
|
>condObject ? exprIsObject1 : exprIsObject2 : Object
|
||
|
>condObject : Object
|
||
|
>exprIsObject1 : Object
|
||
|
>exprIsObject2 : Object
|
||
|
|
||
|
var resultIsAny2 = ((a: string) => a.length) ? exprAny1 : exprAny2;
|
||
|
>resultIsAny2 : any
|
||
|
>((a: string) => a.length) ? exprAny1 : exprAny2 : any
|
||
|
>((a: string) => a.length) : (a: string) => number
|
||
|
>(a: string) => a.length : (a: string) => number
|
||
|
>a : string
|
||
|
>a.length : number
|
||
|
>a : string
|
||
|
>length : number
|
||
|
>exprAny1 : any
|
||
|
>exprAny2 : any
|
||
|
|
||
|
var resultIsBoolean2 = ((a: string) => a.length) ? exprBoolean1 : exprBoolean2;
|
||
|
>resultIsBoolean2 : boolean
|
||
|
>((a: string) => a.length) ? exprBoolean1 : exprBoolean2 : boolean
|
||
|
>((a: string) => a.length) : (a: string) => number
|
||
|
>(a: string) => a.length : (a: string) => number
|
||
|
>a : string
|
||
|
>a.length : number
|
||
|
>a : string
|
||
|
>length : number
|
||
|
>exprBoolean1 : boolean
|
||
|
>exprBoolean2 : boolean
|
||
|
|
||
|
var resultIsNumber2 = ({}) ? exprNumber1 : exprNumber2;
|
||
|
>resultIsNumber2 : number
|
||
|
>({}) ? exprNumber1 : exprNumber2 : number
|
||
|
>({}) : {}
|
||
|
>{} : {}
|
||
|
>exprNumber1 : number
|
||
|
>exprNumber2 : number
|
||
|
|
||
|
var resultIsString2 = ({ a: 1, b: "s" }) ? exprString1 : exprString2;
|
||
|
>resultIsString2 : string
|
||
|
>({ a: 1, b: "s" }) ? exprString1 : exprString2 : string
|
||
|
>({ a: 1, b: "s" }) : { a: number; b: string; }
|
||
|
>{ a: 1, b: "s" } : { a: number; b: string; }
|
||
|
>a : number
|
||
|
>b : string
|
||
|
>exprString1 : string
|
||
|
>exprString2 : string
|
||
|
|
||
|
var resultIsObject2 = ({ a: 1, b: "s" }) ? exprIsObject1 : exprIsObject2;
|
||
|
>resultIsObject2 : Object
|
||
|
>({ a: 1, b: "s" }) ? exprIsObject1 : exprIsObject2 : Object
|
||
|
>({ a: 1, b: "s" }) : { a: number; b: string; }
|
||
|
>{ a: 1, b: "s" } : { a: number; b: string; }
|
||
|
>a : number
|
||
|
>b : string
|
||
|
>exprIsObject1 : Object
|
||
|
>exprIsObject2 : Object
|
||
|
|
||
|
var resultIsAny3 = foo() ? exprAny1 : exprAny2;
|
||
|
>resultIsAny3 : any
|
||
|
>foo() ? exprAny1 : exprAny2 : any
|
||
|
>foo() : void
|
||
|
>foo : () => void
|
||
|
>exprAny1 : any
|
||
|
>exprAny2 : any
|
||
|
|
||
|
var resultIsBoolean3 = new Date() ? exprBoolean1 : exprBoolean2;
|
||
|
>resultIsBoolean3 : boolean
|
||
|
>new Date() ? exprBoolean1 : exprBoolean2 : boolean
|
||
|
>new Date() : Date
|
||
|
>Date : { (): string; new (): Date; new (value: number): Date; new (value: string): Date; new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; prototype: Date; parse(s: string): number; UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; }
|
||
|
>exprBoolean1 : boolean
|
||
|
>exprBoolean2 : boolean
|
||
|
|
||
|
var resultIsNumber3 = new C() ? exprNumber1 : exprNumber2;
|
||
|
>resultIsNumber3 : number
|
||
|
>new C() ? exprNumber1 : exprNumber2 : number
|
||
|
>new C() : C
|
||
|
>C : typeof C
|
||
|
>exprNumber1 : number
|
||
|
>exprNumber2 : number
|
||
|
|
||
|
var resultIsString3 = C.doIt() ? exprString1 : exprString2;
|
||
|
>resultIsString3 : string
|
||
|
>C.doIt() ? exprString1 : exprString2 : string
|
||
|
>C.doIt() : void
|
||
|
>C.doIt : () => void
|
||
|
>C : typeof C
|
||
|
>doIt : () => void
|
||
|
>exprString1 : string
|
||
|
>exprString2 : string
|
||
|
|
||
|
var resultIsObject3 = condObject.valueOf() ? exprIsObject1 : exprIsObject2;
|
||
|
>resultIsObject3 : Object
|
||
|
>condObject.valueOf() ? exprIsObject1 : exprIsObject2 : Object
|
||
|
>condObject.valueOf() : Object
|
||
|
>condObject.valueOf : () => Object
|
||
|
>condObject : Object
|
||
|
>valueOf : () => Object
|
||
|
>exprIsObject1 : Object
|
||
|
>exprIsObject2 : Object
|
||
|
|