Use getInternalName not getLocalName (#20168)

This commit is contained in:
Wesley Wigham 2018-01-08 13:55:50 -08:00 committed by GitHub
parent 16a882eb8b
commit b2f2610b85
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 83 additions and 1 deletions

View file

@ -859,7 +859,7 @@ namespace ts {
statements.push(
setTextRange(
createStatement(
createExtendsHelper(context, getLocalName(node))
createExtendsHelper(context, getInternalName(node))
),
/*location*/ extendsClauseElement
)

View file

@ -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();
};
}

View file

@ -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))
}
}

View file

@ -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
}
}

View file

@ -0,0 +1,8 @@
class A {}
if (true) {
class B extends A {}
const foo = function () {
new B();
}
}