mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 21:06:50 -05:00
Accepted baselines.
This commit is contained in:
@@ -26,7 +26,8 @@ var Parent = (function () {
|
||||
var Child = (function (_super) {
|
||||
__extends(Child, _super);
|
||||
function Child() {
|
||||
_super.apply(this, arguments);
|
||||
var _this = _super.apply(this, arguments) || this;
|
||||
return _this;
|
||||
}
|
||||
Object.defineProperty(Child.prototype, "message", {
|
||||
set: function (str) {
|
||||
|
||||
@@ -25,7 +25,8 @@ var Parent = (function () {
|
||||
var Child = (function (_super) {
|
||||
__extends(Child, _super);
|
||||
function Child() {
|
||||
_super.apply(this, arguments);
|
||||
var _this = _super.apply(this, arguments) || this;
|
||||
return _this;
|
||||
}
|
||||
Object.defineProperty(Child.prototype, "message", {
|
||||
get: function () {
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
tests/cases/compiler/underscoreThisInDerivedClass01.ts(20,13): error TS2399: Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference.
|
||||
|
||||
|
||||
==== tests/cases/compiler/underscoreThisInDerivedClass01.ts (1 errors) ====
|
||||
// @target es5
|
||||
|
||||
// Original test intent:
|
||||
// When arrow functions capture 'this', the lexical 'this' owner
|
||||
// currently captures 'this' using a variable named '_this'.
|
||||
// That means that '_this' becomes a reserved identifier in certain places.
|
||||
//
|
||||
// Constructors have adopted the same identifier name ('_this')
|
||||
// for capturing any potential return values from super calls,
|
||||
// so we expect the same behavior.
|
||||
|
||||
class C {
|
||||
constructor() {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
class D extends C {
|
||||
constructor() {
|
||||
var _this = "uh-oh?";
|
||||
~~~~~
|
||||
!!! error TS2399: Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference.
|
||||
super();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user