diff --git a/src/compiler/transformers/es2015.ts b/src/compiler/transformers/es2015.ts index 65771410ea2..da0fcc73a98 100644 --- a/src/compiler/transformers/es2015.ts +++ b/src/compiler/transformers/es2015.ts @@ -859,7 +859,7 @@ namespace ts { statements.push( setTextRange( createStatement( - createExtendsHelper(context, getLocalName(node)) + createExtendsHelper(context, getInternalName(node)) ), /*location*/ extendsClauseElement ) diff --git a/tests/baselines/reference/classExtensionNameOutput.js b/tests/baselines/reference/classExtensionNameOutput.js new file mode 100644 index 00000000000..8f979863426 --- /dev/null +++ b/tests/baselines/reference/classExtensionNameOutput.js @@ -0,0 +1,38 @@ +//// [classExtensionNameOutput.ts] +class A {} +if (true) { + class B extends A {} + + const foo = function () { + new B(); + } +} + +//// [classExtensionNameOutput.js] +var __extends = (this && this.__extends) || (function () { + var 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 function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var A = /** @class */ (function () { + function A() { + } + return A; +}()); +if (true) { + var B_1 = /** @class */ (function (_super) { + __extends(B, _super); + function B() { + return _super !== null && _super.apply(this, arguments) || this; + } + return B; + }(A)); + var foo = function () { + new B_1(); + }; +} diff --git a/tests/baselines/reference/classExtensionNameOutput.symbols b/tests/baselines/reference/classExtensionNameOutput.symbols new file mode 100644 index 00000000000..7c26d980295 --- /dev/null +++ b/tests/baselines/reference/classExtensionNameOutput.symbols @@ -0,0 +1,16 @@ +=== tests/cases/compiler/classExtensionNameOutput.ts === +class A {} +>A : Symbol(A, Decl(classExtensionNameOutput.ts, 0, 0)) + +if (true) { + class B extends A {} +>B : Symbol(B, Decl(classExtensionNameOutput.ts, 1, 11)) +>A : Symbol(A, Decl(classExtensionNameOutput.ts, 0, 0)) + + const foo = function () { +>foo : Symbol(foo, Decl(classExtensionNameOutput.ts, 4, 7)) + + new B(); +>B : Symbol(B, Decl(classExtensionNameOutput.ts, 1, 11)) + } +} diff --git a/tests/baselines/reference/classExtensionNameOutput.types b/tests/baselines/reference/classExtensionNameOutput.types new file mode 100644 index 00000000000..0bbbb9e2119 --- /dev/null +++ b/tests/baselines/reference/classExtensionNameOutput.types @@ -0,0 +1,20 @@ +=== tests/cases/compiler/classExtensionNameOutput.ts === +class A {} +>A : A + +if (true) { +>true : true + + class B extends A {} +>B : B +>A : A + + const foo = function () { +>foo : () => void +>function () { new B(); } : () => void + + new B(); +>new B() : B +>B : typeof B + } +} diff --git a/tests/cases/compiler/classExtensionNameOutput.ts b/tests/cases/compiler/classExtensionNameOutput.ts new file mode 100644 index 00000000000..3992780b0fb --- /dev/null +++ b/tests/cases/compiler/classExtensionNameOutput.ts @@ -0,0 +1,8 @@ +class A {} +if (true) { + class B extends A {} + + const foo = function () { + new B(); + } +} \ No newline at end of file