-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Component commits: 5810765 Emit defineProperty calls before param prop assignments Note that I restricted this to --useDefineForClassFields is true. Nothing changes when it's off. I think this is the correct fix for a patch release. However, in principal there's nothing wrong with moving parameter property initialisation after property declaration initialisation. It would be Extremely Bad and Wrong to rely on this working: ```ts class C { p = this.q // what is q? constructor(public q: number) { } } ``` But today it does, and probably somebody relies on it without knowing. ec79590 Put parameter property initialiser into defineProperty's value be86355 Merge branch 'master' into fix-defineProperty-parameter-property-emit 8ff59b9 Combine ES5/ESNext into one test
- Loading branch information
Showing
14 changed files
with
356 additions
and
207 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 118 additions & 0 deletions
118
tests/baselines/reference/defineProperty(target=es5).js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
//// [defineProperty.ts] | ||
var x: "p" = "p" | ||
class A { | ||
a = this.y | ||
b | ||
["computed"] = 13 | ||
;[x] = 14 | ||
m() { } | ||
constructor(public readonly y: number) { } | ||
z = this.y | ||
declare notEmitted; | ||
} | ||
class B { | ||
} | ||
class C extends B { | ||
z = this.ka | ||
constructor(public ka: number) { | ||
super() | ||
} | ||
ki = this.ka | ||
} | ||
|
||
|
||
//// [defineProperty.js] | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
var _a; | ||
var x = "p"; | ||
var A = /** @class */ (function () { | ||
function A(y) { | ||
Object.defineProperty(this, "y", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: y | ||
}); | ||
Object.defineProperty(this, "a", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: this.y | ||
}); | ||
Object.defineProperty(this, "b", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
Object.defineProperty(this, "computed", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: 13 | ||
}); | ||
Object.defineProperty(this, _a, { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: 14 | ||
}); | ||
Object.defineProperty(this, "z", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: this.y | ||
}); | ||
} | ||
Object.defineProperty(A.prototype, "m", { | ||
enumerable: false, | ||
configurable: true, | ||
writable: true, | ||
value: function () { } | ||
}); | ||
return A; | ||
}()); | ||
_a = x; | ||
var B = /** @class */ (function () { | ||
function B() { | ||
} | ||
return B; | ||
}()); | ||
var C = /** @class */ (function (_super) { | ||
__extends(C, _super); | ||
function C(ka) { | ||
var _this = _super.call(this) || this; | ||
Object.defineProperty(_this, "ka", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: ka | ||
}); | ||
Object.defineProperty(_this, "z", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: _this.ka | ||
}); | ||
Object.defineProperty(_this, "ki", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: _this.ka | ||
}); | ||
return _this; | ||
} | ||
return C; | ||
}(B)); |
65 changes: 65 additions & 0 deletions
65
tests/baselines/reference/defineProperty(target=es5).symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
=== tests/cases/conformance/classes/propertyMemberDeclarations/defineProperty.ts === | ||
var x: "p" = "p" | ||
>x : Symbol(x, Decl(defineProperty.ts, 0, 3)) | ||
|
||
class A { | ||
>A : Symbol(A, Decl(defineProperty.ts, 0, 16)) | ||
|
||
a = this.y | ||
>a : Symbol(A.a, Decl(defineProperty.ts, 1, 9)) | ||
>this.y : Symbol(A.y, Decl(defineProperty.ts, 7, 16)) | ||
>this : Symbol(A, Decl(defineProperty.ts, 0, 16)) | ||
>y : Symbol(A.y, Decl(defineProperty.ts, 7, 16)) | ||
|
||
b | ||
>b : Symbol(A.b, Decl(defineProperty.ts, 2, 14)) | ||
|
||
["computed"] = 13 | ||
>["computed"] : Symbol(A["computed"], Decl(defineProperty.ts, 3, 5)) | ||
>"computed" : Symbol(A["computed"], Decl(defineProperty.ts, 3, 5)) | ||
|
||
;[x] = 14 | ||
>[x] : Symbol(A[x], Decl(defineProperty.ts, 5, 5)) | ||
>x : Symbol(x, Decl(defineProperty.ts, 0, 3)) | ||
|
||
m() { } | ||
>m : Symbol(A.m, Decl(defineProperty.ts, 5, 13)) | ||
|
||
constructor(public readonly y: number) { } | ||
>y : Symbol(A.y, Decl(defineProperty.ts, 7, 16)) | ||
|
||
z = this.y | ||
>z : Symbol(A.z, Decl(defineProperty.ts, 7, 46)) | ||
>this.y : Symbol(A.y, Decl(defineProperty.ts, 7, 16)) | ||
>this : Symbol(A, Decl(defineProperty.ts, 0, 16)) | ||
>y : Symbol(A.y, Decl(defineProperty.ts, 7, 16)) | ||
|
||
declare notEmitted; | ||
>notEmitted : Symbol(A.notEmitted, Decl(defineProperty.ts, 8, 14)) | ||
} | ||
class B { | ||
>B : Symbol(B, Decl(defineProperty.ts, 10, 1)) | ||
} | ||
class C extends B { | ||
>C : Symbol(C, Decl(defineProperty.ts, 12, 1)) | ||
>B : Symbol(B, Decl(defineProperty.ts, 10, 1)) | ||
|
||
z = this.ka | ||
>z : Symbol(C.z, Decl(defineProperty.ts, 13, 19)) | ||
>this.ka : Symbol(C.ka, Decl(defineProperty.ts, 15, 16)) | ||
>this : Symbol(C, Decl(defineProperty.ts, 12, 1)) | ||
>ka : Symbol(C.ka, Decl(defineProperty.ts, 15, 16)) | ||
|
||
constructor(public ka: number) { | ||
>ka : Symbol(C.ka, Decl(defineProperty.ts, 15, 16)) | ||
|
||
super() | ||
>super : Symbol(B, Decl(defineProperty.ts, 10, 1)) | ||
} | ||
ki = this.ka | ||
>ki : Symbol(C.ki, Decl(defineProperty.ts, 17, 5)) | ||
>this.ka : Symbol(C.ka, Decl(defineProperty.ts, 15, 16)) | ||
>this : Symbol(C, Decl(defineProperty.ts, 12, 1)) | ||
>ka : Symbol(C.ka, Decl(defineProperty.ts, 15, 16)) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.