8000 Merge pull request #3380 from Microsoft/emitterNameRewriting · imskojs/TypeScript@ce2d914 · GitHub
[go: up one dir, main page]

Skip to content

Commit ce2d914

Browse files
committed
Merge pull request microsoft#3380 from Microsoft/emitterNameRewriting
Emitter name rewriting
2 parents acda704 + 8e096d5 commit ce2d914

File tree

12 files changed

+298
-332
lines changed

12 files changed

+298
-332
lines changed

src/compiler/checker.ts

Lines changed: 94 additions & 91 deletions
Large diffs are not rendered by default.

src/compiler/emitter.ts

Lines changed: 169 additions & 211 deletions
Large diffs are not rendered by default.

src/compiler/types.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,7 +1420,10 @@ module ts {
14201420
/* @internal */
14211421
export interface EmitResolver {
14221422
hasGlobalName(name: string): boolean;
1423-
getExpressionNameSubstitution(node: Identifier, getGeneratedNameForNode: (node: Node) => string): string;
1423+
getReferencedExportContainer(node: Identifier): SourceFile | ModuleDeclaration | EnumDeclaration;
1424+
getReferencedImportDeclaration(node: Identifier): Declaration;
1425+
getReferencedNestedRedeclaration(node: Identifier): Declaration;
1426+
isNestedRedeclaration(node: Declaration): boolean;
14241427
isValueAliasDeclaration(node: Node): boolean;
14251428
isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean;
14261429
isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean;
@@ -1435,12 +1438,11 @@ module ts {
14351438
isEntityNameVisible(entityName: EntityName | Expression, enclosingDeclaration: Node): SymbolVisibilityResult;
14361439
// Returns the constant value this property access resolves to, or 'undefined' for a non-constant
14371440
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
1438-
resolvesToSomeValue(location: Node, name: string): boolean;
14391441
getBlockScopedVariableId(node: Identifier): number;
14401442
getReferencedValueDeclaration(reference: Identifier): Declaration;
1441-
serializeTypeOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): string | string[];
1442-
serializeParameterTypesOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): (string | string[])[];
1443-
serializeReturnTypeOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): string | string[];
1443+
serializeTypeOfNode(node: Node): string | string[];
1444+
serializeParameterTypesOfNode(node: Node): (string | string[])[];
1445+
serializeReturnTypeOfNode(node: Node): string | string[];
14441446
}
14451447

14461448
export const enum SymbolFlags {
@@ -1517,6 +1519,8 @@ module ts {
15171519
HasExports = Class | Enum | Module,
15181520
HasMembers = Class | Interface | TypeLiteral | ObjectLiteral,
15191521

1522+
BlockScoped = BlockScopedVariable | Class | Enum,
1523+
15201524
PropertyOrAccessor = Property | Accessor,
15211525
Export = ExportNamespace | ExportType | ExportValue,
15221526
}
@@ -1548,6 +1552,7 @@ module ts {
15481552
unionType?: UnionType; // Containing union type for union property
15491553
resolvedExports?: SymbolTable; // Resolved exports of module
15501554
exportsChecked?: boolean; // True if exports of external module have been checked
1555+
isNestedRedeclaration?: boolean; // True if symbol is block scoped redeclaration
15511556
}
15521557

15531558
/* @internal */

tests/baselines/reference/ES5For-of17.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ for (let v of []) {
1111
for (var _i = 0, _a = []; _i < _a.length; _i++) {
1212
var v = _a[_i];
1313
v;
14-
for (var _b = 0, _c = [v]; _b < _c.length; _b++) {
14+
for (var _b = 0, _c = [v_1]; _b < _c.length; _b++) {
1515
var v_1 = _c[_b];
1616
var x = v_1;
1717
v_1++;

tests/baselines/reference/ES5For-of20.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ for (let v of []) {
1010
for (var _i = 0, _a = []; _i < _a.length; _i++) {
1111
var v = _a[_i];
1212
var v_1;
13-
for (var _b = 0, _c = [v]; _b < _c.length; _b++) {
13+
for (var _b = 0, _c = [v_2]; _b < _c.length; _b++) {
1414
var v_2 = _c[_b];
1515
var v_3;
1616
}

tests/baselines/reference/classDeclarationBlockScoping1.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ var C = (function () {
1414
return C;
1515
})();
1616
{
17-
var C = (function () {
18-
function C() {
17+
var C_1 = (function () {
18+
function C_1() {
1919
}
20-
return C;
20+
return C_1;
2121
})();
2222
}

tests/baselines/reference/cl 10000 assDeclarationBlockScoping2.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ function f() {
1818
})();
1919
var c1 = C;
2020
{
21-
var C = (function () {
22-
function C() {
21+
var C_1 = (function () {
22+
function C_1() {
2323
}
24-
return C;
24+
return C_1;
2525
})();
26-
var c2 = C;
26+
var c2 = C_1;
2727
}
2828
return C === c1;
2929
}

tests/baselines/reference/exportsAndImports3-amd.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,25 +40,25 @@ define(["require", "exports"], function (require, exports) {
4040
exports.v1 = exports.v;
4141
function f() { }
4242
exports.f = f;
43-
exports.f1 = exports.f;
43+
exports.f1 = f;
4444
var C = (function () {
4545
function C() {
4646
}
4747
return C;
4848
})();
4949
exports.C = C;
50-
exports.C1 = exports.C;
50+
exports.C1 = C;
5151
(function (E) {
5252
E[E["A"] = 0] = "A";
5353
E[E["B"] = 1] = "B";
5454
E[E["C"] = 2] = "C";
5555
})(exports.E || (exports.E = {}));
5656
var E = exports.E;
57-
exports.E1 = exports.E;
57+
exports.E1 = E;
5858
var M;
5959
(function (M) {
6060
})(M = exports.M || (exports.M = {}));
61-
exports.M1 = exports.M;
61+
exports.M1 = M;
6262
exports.a = M.x;
6363
exports.a1 = exports.a;
6464
});

tests/baselines/reference/exportsAndImports3.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,25 @@ exports.v = 1;
3939
exports.v1 = exports.v;
4040
function f() { }
4141
exports.f = f;
42-
exports.f1 = exports.f;
42+
exports.f1 = f;
4343
var C = (function () {
4444
function C() {
4545
}
4646
return C;
4747
})();
4848
exports.C = C;
49-
exports.C1 = exports.C;
49+
exports.C1 = C;
5050
(function (E) {
5151
E[E["A"] = 0] = "A";
5252
E[E["B"] = 1] = "B";
5353
E[E["C"] = 2] = "C";
5454
})(exports.E || (exports.E = {}));
5555
var E = exports.E;
56-
exports.E1 = exports.E;
56+
exports.E1 = E;
5757
var M;
5858
(function (M) {
5959
})(M = exports.M || (exports.M = {}));
60-
exports.M1 = exports.M;
60+
exports.M1 = M;
6161
exports.a = M.x;
6262
exports.a1 = exports.a;
6363
//// [t2.js]

tests/baselines/reference/localTypes1.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,12 @@ function f3(b) {
202202
return a;
203203
}
204204
else {
205-
var A = (function () {
206-
function A() {
205+
var A_1 = (function () {
206+
function A_1() {
207207
}
208-
return A;
208+
return A_1;
209209
})();
210-
var c = [new A()];
210+
var c = [new A_1()];
211211
c[0].x = E.B;
212212
return c;
213213
}

0 commit comments

Comments
 (0)
0