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 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273
|
//// [classUpdateTests.ts]
//
// test codegen for instance properties
//
class A {
public p1 = 0;
private p2 = 0;
p3;
}
class B {
public p1 = 0;
private p2 = 0;
p3;
constructor() {}
}
class C {
constructor(public p1=0, private p2=0, p3=0) {}
}
//
// test requirements for super calls
//
class D { // NO ERROR
}
class E extends D { // NO ERROR
public p1 = 0;
}
class F extends E {
constructor() {} // ERROR - super call required
}
class G extends D {
public p1 = 0;
constructor() { super(); } // NO ERROR
}
class H {
constructor() { super(); } // ERROR - no super call allowed
}
class I extends Object {
constructor() { super(); } // ERROR - no super call allowed
}
class J extends G {
constructor(public p1:number) {
super(); // NO ERROR
}
}
class K extends G {
constructor(public p1:number) { // ERROR
var i = 0;
super();
}
}
class L extends G {
constructor(private p1:number) {
super(); // NO ERROR
}
}
class M extends G {
constructor(private p1:number) { // ERROR
var i = 0;
super();
}
}
//
// test this reference in field initializers
//
class N {
public p1 = 0;
public p2 = this.p1;
constructor() {
this.p2 = 0;
}
}
//
// test error on property declarations within class constructors
//
class O {
constructor() {
public p1 = 0; // ERROR
}
}
class P {
constructor() {
private p1 = 0; // ERROR
}
}
class Q {
constructor() {
public this.p1 = 0; // ERROR
}
}
class R {
constructor() {
private this.p1 = 0; // ERROR
}
}
//// [classUpdateTests.js]
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
//
// test codegen for instance properties
//
var A = (function () {
function A() {
this.p1 = 0;
this.p2 = 0;
}
return A;
}());
var B = (function () {
function B() {
this.p1 = 0;
this.p2 = 0;
}
return B;
}());
var C = (function () {
function C(p1, p2, p3) {
if (p1 === void 0) { p1 = 0; }
if (p2 === void 0) { p2 = 0; }
if (p3 === void 0) { p3 = 0; }
this.p1 = p1;
this.p2 = p2;
}
return C;
}());
//
// test requirements for super calls
//
var D = (function () {
function D() {
}
return D;
}());
var E = (function (_super) {
__extends(E, _super);
function E() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.p1 = 0;
return _this;
}
return E;
}(D));
var F = (function (_super) {
__extends(F, _super);
function F() {
var _this = this;
return _this;
} // ERROR - super call required
return F;
}(E));
var G = (function (_super) {
__extends(G, _super);
function G() {
var _this = _super.call(this) || this;
_this.p1 = 0;
return _this;
} // NO ERROR
return G;
}(D));
var H = (function () {
function H() {
_this = _super.call(this) || this;
} // ERROR - no super call allowed
return H;
}());
var I = (function (_super) {
__extends(I, _super);
function I() {
return _super.call(this) || this;
} // ERROR - no super call allowed
return I;
}(Object));
var J = (function (_super) {
__extends(J, _super);
function J(p1) {
var _this = _super.call(this) || this;
_this.p1 = p1;
return _this;
}
return J;
}(G));
var K = (function (_super) {
__extends(K, _super);
function K(p1) {
var _this = this;
_this.p1 = p1;
var i = 0;
_this = _super.call(this) || this;
return _this;
}
return K;
}(G));
var L = (function (_super) {
__extends(L, _super);
function L(p1) {
var _this = _super.call(this) || this;
_this.p1 = p1;
return _this;
}
return L;
}(G));
var M = (function (_super) {
__extends(M, _super);
function M(p1) {
var _this = this;
_this.p1 = p1;
var i = 0;
_this = _super.call(this) || this;
return _this;
}
return M;
}(G));
//
// test this reference in field initializers
//
var N = (function () {
function N() {
this.p1 = 0;
this.p2 = this.p1;
this.p2 = 0;
}
return N;
}());
//
// test error on property declarations within class constructors
//
var O = (function () {
function O() {
this.p1 = 0; // ERROR
}
return O;
}());
var P = (function () {
function P() {
this.p1 = 0; // ERROR
}
return P;
}());
var Q = (function () {
function Q() {
this.p1 = 0; // ERROR
}
return Q;
}());
var R = (function () {
function R() {
this.p1 = 0; // ERROR
}
return R;
}());
|