1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
|
=== tests/cases/compiler/objectCreationOfElementAccessExpression.ts ===
class Food {
>Food : Food
private amount: number;
>amount : number
constructor(public name: string) {
>name : string
this.amount = 100;
>this.amount = 100 : 100
>this.amount : number
>this : this
>amount : number
>100 : 100
}
public eat(amountToEat: number): boolean {
>eat : (amountToEat: number) => boolean
>amountToEat : number
this.amount -= amountToEat;
>this.amount -= amountToEat : number
>this.amount : number
>this : this
>amount : number
>amountToEat : number
if (this.amount <= 0) {
>this.amount <= 0 : boolean
>this.amount : number
>this : this
>amount : number
>0 : 0
this.amount = 0;
>this.amount = 0 : 0
>this.amount : number
>this : this
>amount : number
>0 : 0
return false;
>false : false
}
else {
return true;
>true : true
}
}
}
class MonsterFood extends Food {
>MonsterFood : MonsterFood
>Food : Food
constructor(name: string, public flavor: string) {
>name : string
>flavor : string
super(name);
>super(name) : void
>super : typeof Food
>name : string
}
}
class IceCream extends MonsterFood {
>IceCream : IceCream
>MonsterFood : MonsterFood
private isDairyFree: boolean;
>isDairyFree : boolean
constructor(public flavor: string) {
>flavor : string
super("Ice Cream", flavor);
>super("Ice Cream", flavor) : void
>super : typeof MonsterFood
>"Ice Cream" : "Ice Cream"
>flavor : string
}
}
class Cookie extends MonsterFood {
>Cookie : Cookie
>MonsterFood : MonsterFood
constructor(public flavor: string, public isGlutenFree: boolean) {
>flavor : string
>isGlutenFree : boolean
super("Cookie", flavor);
>super("Cookie", flavor) : void
>super : typeof MonsterFood
>"Cookie" : "Cookie"
>flavor : string
}
}
class PetFood extends Food {
>PetFood : PetFood
>Food : Food
constructor(name: string, public whereToBuy: number) {
>name : string
>whereToBuy : number
super(name);
>super(name) : void
>super : typeof Food
>name : string
}
}
class ExpensiveOrganicDogFood extends PetFood {
>ExpensiveOrganicDogFood : ExpensiveOrganicDogFood
>PetFood : PetFood
constructor(public whereToBuy: number) {
>whereToBuy : number
super("Origen", whereToBuy);
>super("Origen", whereToBuy) : void
>super : typeof PetFood
>"Origen" : "Origen"
>whereToBuy : number
}
}
class ExpensiveOrganicCatFood extends PetFood {
>ExpensiveOrganicCatFood : ExpensiveOrganicCatFood
>PetFood : PetFood
constructor(public whereToBuy: number, public containsFish: boolean) {
>whereToBuy : number
>containsFish : boolean
super("Nature's Logic", whereToBuy);
>super("Nature's Logic", whereToBuy) : void
>super : typeof PetFood
>"Nature's Logic" : "Nature's Logic"
>whereToBuy : number
}
}
class Slug {
>Slug : Slug
// This is NOT a food!!!
}
// ElementAccessExpressions can only contain one expression. There should be a parse error here.
var foods = new PetFood[new IceCream('Mint chocolate chip') , Cookie('Chocolate chip', false) , new Cookie('Peanut butter', true)];
>foods : any
>new PetFood[new IceCream('Mint chocolate chip') , Cookie('Chocolate chip', false) , new Cookie('Peanut butter', true)] : any
>PetFood[new IceCream('Mint chocolate chip') , Cookie('Chocolate chip', false) , new Cookie('Peanut butter', true)] : any
>PetFood : typeof PetFood
>new IceCream('Mint chocolate chip') , Cookie('Chocolate chip', false) , new Cookie('Peanut butter', true) : Cookie
>new IceCream('Mint chocolate chip') , Cookie('Chocolate chip', false) : any
>new IceCream('Mint chocolate chip') : IceCream
>IceCream : typeof IceCream
>'Mint chocolate chip' : "Mint chocolate chip"
>Cookie('Chocolate chip', false) : any
>Cookie : typeof Cookie
>'Chocolate chip' : "Chocolate chip"
>false : false
>new Cookie('Peanut butter', true) : Cookie
>Cookie : typeof Cookie
>'Peanut butter' : "Peanut butter"
>true : true
var foods2: MonsterFood[] = new PetFood[new IceCream('Mint chocolate chip') , Cookie('Chocolate chip', false) , new Cookie('Peanut butter', true)];
>foods2 : MonsterFood[]
>new PetFood[new IceCream('Mint chocolate chip') , Cookie('Chocolate chip', false) , new Cookie('Peanut butter', true)] : any
>PetFood[new IceCream('Mint chocolate chip') , Cookie('Chocolate chip', false) , new Cookie('Peanut butter', true)] : any
>PetFood : typeof PetFood
>new IceCream('Mint chocolate chip') , Cookie('Chocolate chip', false) , new Cookie('Peanut butter', true) : Cookie
>new IceCream('Mint chocolate chip') , Cookie('Chocolate chip', false) : any
>new IceCream('Mint chocolate chip') : IceCream
>IceCream : typeof IceCream
>'Mint chocolate chip' : "Mint chocolate chip"
>Cookie('Chocolate chip', false) : any
>Cookie : typeof Cookie
>'Chocolate chip' : "Chocolate chip"
>false : false
>new Cookie('Peanut butter', true) : Cookie
>Cookie : typeof Cookie
>'Peanut butter' : "Peanut butter"
>true : true
|