mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge pull request #2701 from Microsoft/superAnnoyingEmitInEs6Classes
Don't emit '_this' when encountering 'super' in ES6 emit
This commit is contained in:
@@ -5582,7 +5582,7 @@ module ts {
|
||||
needToCaptureLexicalThis = false;
|
||||
while (container && container.kind === SyntaxKind.ArrowFunction) {
|
||||
container = getSuperContainer(container, /*includeFunctions*/ true);
|
||||
needToCaptureLexicalThis = true;
|
||||
needToCaptureLexicalThis = languageVersion < ScriptTarget.ES6;
|
||||
}
|
||||
|
||||
// topmost container must be something that is directly nested in the class declaration
|
||||
|
||||
@@ -23,7 +23,6 @@ class Base {
|
||||
}
|
||||
class C extends Base {
|
||||
foo() {
|
||||
var _this = this;
|
||||
(() => {
|
||||
var obj = {
|
||||
[super.bar()]() { } // needs capture
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
//// [emitClassDeclarationWithSuperMethodCall01.ts]
|
||||
|
||||
class Parent {
|
||||
foo() {
|
||||
}
|
||||
}
|
||||
|
||||
class Foo extends Parent {
|
||||
foo() {
|
||||
var x = () => super.foo();
|
||||
}
|
||||
}
|
||||
|
||||
//// [emitClassDeclarationWithSuperMethodCall01.js]
|
||||
class Parent {
|
||||
foo() {
|
||||
}
|
||||
}
|
||||
class Foo extends Parent {
|
||||
foo() {
|
||||
var x = () => super.foo();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithSuperMethodCall01.ts ===
|
||||
|
||||
class Parent {
|
||||
>Parent : Parent
|
||||
|
||||
foo() {
|
||||
>foo : () => void
|
||||
}
|
||||
}
|
||||
|
||||
class Foo extends Parent {
|
||||
>Foo : Foo
|
||||
>Parent : Parent
|
||||
|
||||
foo() {
|
||||
>foo : () => void
|
||||
|
||||
var x = () => super.foo();
|
||||
>x : () => void
|
||||
>() => super.foo() : () => void
|
||||
>super.foo() : void
|
||||
>super.foo : () => void
|
||||
>super : Parent
|
||||
>foo : () => void
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
// @target: ES5
|
||||
module M {
|
||||
class C {
|
||||
decorator(target: Object, key: string): void { }
|
||||
|
||||
@this.decorator
|
||||
method() { }
|
||||
}
|
||||
// @target: ES5
|
||||
module M {
|
||||
class C {
|
||||
decorator(target: Object, key: string): void { }
|
||||
|
||||
@this.decorator
|
||||
method() { }
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
//@target: es6
|
||||
|
||||
class Parent {
|
||||
foo() {
|
||||
}
|
||||
}
|
||||
|
||||
class Foo extends Parent {
|
||||
foo() {
|
||||
var x = () => super.foo();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user