2014-08-15 23:33:16 +02:00
|
|
|
=== tests/cases/compiler/arrayLiteralTypeInference.ts ===
|
|
|
|
class Action {
|
2015-04-16 01:44:20 +02:00
|
|
|
>Action : Action
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
id: number;
|
2015-04-16 01:44:20 +02:00
|
|
|
>id : number
|
2014-08-15 23:33:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
class ActionA extends Action {
|
2015-04-16 01:44:20 +02:00
|
|
|
>ActionA : ActionA
|
|
|
|
>Action : Action
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
value: string;
|
2015-04-16 01:44:20 +02:00
|
|
|
>value : string
|
2014-08-15 23:33:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
class ActionB extends Action {
|
2015-04-16 01:44:20 +02:00
|
|
|
>ActionB : ActionB
|
|
|
|
>Action : Action
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
trueNess: boolean;
|
2015-04-16 01:44:20 +02:00
|
|
|
>trueNess : boolean
|
2014-08-15 23:33:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var x1: Action[] = [
|
2015-04-16 01:44:20 +02:00
|
|
|
>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; }
|
2015-04-16 01:44:20 +02:00
|
|
|
>id : number
|
2015-04-13 21:36:11 +02:00
|
|
|
>2 : number
|
2015-04-16 01:44:20 +02:00
|
|
|
>trueness : boolean
|
2015-04-13 21:36:11 +02:00
|
|
|
>false : boolean
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
{ id: 3, name: "three" }
|
|
|
|
>{ id: 3, name: "three" } : { id: number; name: string; }
|
2015-04-16 01:44:20 +02:00
|
|
|
>id : number
|
2015-04-13 21:36:11 +02:00
|
|
|
>3 : number
|
2015-04-16 01:44:20 +02:00
|
|
|
>name : string
|
2015-04-13 21:36:11 +02:00
|
|
|
>"three" : string
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
var x2: Action[] = [
|
2015-04-16 01:44:20 +02:00
|
|
|
>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
|
2015-04-16 01:44:20 +02:00
|
|
|
>ActionA : typeof ActionA
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
new ActionB()
|
|
|
|
>new ActionB() : ActionB
|
2015-04-16 01:44:20 +02:00
|
|
|
>ActionB : typeof ActionB
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
var x3: Action[] = [
|
2015-04-16 01:44:20 +02:00
|
|
|
>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
|
2015-04-16 01:44:20 +02:00
|
|
|
>Action : typeof Action
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
new ActionA(),
|
|
|
|
>new ActionA() : ActionA
|
2015-04-16 01:44:20 +02:00
|
|
|
>ActionA : typeof ActionA
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
new ActionB()
|
|
|
|
>new ActionB() : ActionB
|
2015-04-16 01:44:20 +02:00
|
|
|
>ActionB : typeof ActionB
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
var z1: { id: number }[] =
|
2015-04-16 01:44:20 +02:00
|
|
|
>z1 : { id: number; }[]
|
|
|
|
>id : number
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
[
|
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; }
|
2015-04-16 01:44:20 +02:00
|
|
|
>id : number
|
2015-04-13 21:36:11 +02:00
|
|
|
>2 : number
|
2015-04-16 01:44:20 +02:00
|
|
|
>trueness : boolean
|
2015-04-13 21:36:11 +02:00
|
|
|
>false : boolean
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
{ id: 3, name: "three" }
|
|
|
|
>{ id: 3, name: "three" } : { id: number; name: string; }
|
2015-04-16 01:44:20 +02:00
|
|
|
>id : number
|
2015-04-13 21:36:11 +02:00
|
|
|
>3 : number
|
2015-04-16 01:44:20 +02:00
|
|
|
>name : string
|
2015-04-13 21:36:11 +02:00
|
|
|
>"three" : string
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
var z2: { id: number }[] =
|
2015-04-16 01:44:20 +02:00
|
|
|
>z2 : { id: number; }[]
|
|
|
|
>id : number
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
[
|
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
|
2015-04-16 01:44:20 +02:00
|
|
|
>ActionA : typeof ActionA
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
new ActionB()
|
|
|
|
>new ActionB() : ActionB
|
2015-04-16 01:44:20 +02:00
|
|
|
>ActionB : typeof ActionB
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
var z3: { id: number }[] =
|
2015-04-16 01:44:20 +02:00
|
|
|
>z3 : { id: number; }[]
|
|
|
|
>id : number
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
[
|
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
|
2015-04-16 01:44:20 +02:00
|
|
|
>Action : typeof Action
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
new ActionA(),
|
|
|
|
>new ActionA() : ActionA
|
2015-04-16 01:44:20 +02:00
|
|
|
>ActionA : typeof ActionA
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
new ActionB()
|
|
|
|
>new ActionB() : ActionB
|
2015-04-16 01:44:20 +02:00
|
|
|
>ActionB : typeof ActionB
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|