From b476815f76eac2cbc3704fa91be5e22ef76fff8b Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 6 Sep 2016 11:31:20 -0700 Subject: [PATCH] Added test for '_this'. --- .../underscoreThisInDerivedClass01.ts | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/cases/compiler/underscoreThisInDerivedClass01.ts diff --git a/tests/cases/compiler/underscoreThisInDerivedClass01.ts b/tests/cases/compiler/underscoreThisInDerivedClass01.ts new file mode 100644 index 00000000000..0d3f5849cb1 --- /dev/null +++ b/tests/cases/compiler/underscoreThisInDerivedClass01.ts @@ -0,0 +1,23 @@ +// @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?"; + super(); + } +} \ No newline at end of file