2014-08-15 23:33:16 +02:00
|
|
|
=== tests/cases/compiler/arrayLiteralTypeInference.ts ===
|
|
|
|
class Action {
|
|
|
|
>Action : Action
|
|
|
|
|
|
|
|
id: number;
|
|
|
|
>id : number
|
|
|
|
}
|
|
|
|
|
|
|
|
class ActionA extends Action {
|
|
|
|
>ActionA : ActionA
|
|
|
|
>Action : Action
|
|
|
|
|
|
|
|
value: string;
|
|
|
|
>value : string
|
|
|
|
}
|
|
|
|
|
|
|
|
class ActionB extends Action {
|
|
|
|
>ActionB : ActionB
|
|
|
|
>Action : Action
|
|
|
|
|
|
|
|
trueNess: boolean;
|
|
|
|
>trueNess : boolean
|
|
|
|
}
|
|
|
|
|
|
|
|
var x1: Action[] = [
|
|
|
|
>x1 : Action[]
|
|
|
|
>Action : Action
|
2014-10-18 01:53:18 +02:00
|
|
|
>[ { id: 2, trueness: false }, { id: 3, name: "three" }] : ({ id: number; trueness: boolean; } | { id: number; name: string; })[]
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
{ id: 2, trueness: false },
|
|
|
|
>{ id: 2, trueness: false } : { id: number; trueness: boolean; }
|
|
|
|
>id : number
|
|
|
|
>trueness : boolean
|
|
|
|
|
|
|
|
{ id: 3, name: "three" }
|
|
|
|
>{ id: 3, name: "three" } : { id: number; name: string; }
|
|
|
|
>id : number
|
|
|
|
>name : string
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
var x2: Action[] = [
|
|
|
|
>x2 : Action[]
|
|
|
|
>Action : Action
|
2014-10-18 01:53:18 +02:00
|
|
|
>[ new ActionA(), new ActionB()] : (ActionA | ActionB)[]
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
new ActionA(),
|
|
|
|
>new ActionA() : ActionA
|
|
|
|
>ActionA : typeof ActionA
|
|
|
|
|
|
|
|
new ActionB()
|
|
|
|
>new ActionB() : ActionB
|
|
|
|
>ActionB : typeof ActionB
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
var x3: Action[] = [
|
|
|
|
>x3 : Action[]
|
|
|
|
>Action : Action
|
2014-08-22 03:39:46 +02:00
|
|
|
>[ new Action(), new ActionA(), new ActionB()] : Action[]
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
new Action(),
|
|
|
|
>new Action() : Action
|
|
|
|
>Action : typeof Action
|
|
|
|
|
|
|
|
new ActionA(),
|
|
|
|
>new ActionA() : ActionA
|
|
|
|
>ActionA : typeof ActionA
|
|
|
|
|
|
|
|
new ActionB()
|
|
|
|
>new ActionB() : ActionB
|
|
|
|
>ActionB : typeof ActionB
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
var z1: { id: number }[] =
|
|
|
|
>z1 : { id: number; }[]
|
|
|
|
>id : number
|
|
|
|
|
|
|
|
[
|
2014-10-18 01:53:18 +02:00
|
|
|
>[ { id: 2, trueness: false }, { id: 3, name: "three" } ] : ({ id: number; trueness: boolean; } | { id: number; name: string; })[]
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
{ id: 2, trueness: false },
|
|
|
|
>{ id: 2, trueness: false } : { id: number; trueness: boolean; }
|
|
|
|
>id : number
|
|
|
|
>trueness : boolean
|
|
|
|
|
|
|
|
{ id: 3, name: "three" }
|
|
|
|
>{ id: 3, name: "three" } : { id: number; name: string; }
|
|
|
|
>id : number
|
|
|
|
>name : string
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
var z2: { id: number }[] =
|
|
|
|
>z2 : { id: number; }[]
|
|
|
|
>id : number
|
|
|
|
|
|
|
|
[
|
2014-10-18 01:53:18 +02:00
|
|
|
>[ new ActionA(), new ActionB() ] : (ActionA | ActionB)[]
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
new ActionA(),
|
|
|
|
>new ActionA() : ActionA
|
|
|
|
>ActionA : typeof ActionA
|
|
|
|
|
|
|
|
new ActionB()
|
|
|
|
>new ActionB() : ActionB
|
|
|
|
>ActionB : typeof ActionB
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
var z3: { id: number }[] =
|
|
|
|
>z3 : { id: number; }[]
|
|
|
|
>id : number
|
|
|
|
|
|
|
|
[
|
2014-10-13 15:56:58 +02:00
|
|
|
>[ new Action(), new ActionA(), new ActionB() ] : Action[]
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
new Action(),
|
|
|
|
>new Action() : Action
|
|
|
|
>Action : typeof Action
|
|
|
|
|
|
|
|
new ActionA(),
|
|
|
|
>new ActionA() : ActionA
|
|
|
|
>ActionA : typeof ActionA
|
|
|
|
|
|
|
|
new ActionB()
|
|
|
|
>new ActionB() : ActionB
|
|
|
|
>ActionB : typeof ActionB
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|