Skip to content

Commit 5f9f9e3

Browse files
fix(44477): emit full path to access expressions in comments (#44545)
Co-authored-by: Wesley Wigham <wewigham@microsoft.com>
1 parent 4abad55 commit 5f9f9e3

40 files changed

+253
-257
lines changed

src/compiler/transformers/ts.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3368,13 +3368,9 @@ namespace ts {
33683368
const substitute = typeof constantValue === "string" ? factory.createStringLiteral(constantValue) : factory.createNumericLiteral(constantValue);
33693369
if (!compilerOptions.removeComments) {
33703370
const originalNode = getOriginalNode(node, isAccessExpression);
3371-
const propertyName = isPropertyAccessExpression(originalNode)
3372-
? declarationNameToString(originalNode.name)
3373-
: safeMultiLineComment(getTextOfNode(originalNode.argumentExpression));
33743371

3375-
addSyntheticTrailingComment(substitute, SyntaxKind.MultiLineCommentTrivia, ` ${propertyName} `);
3372+
addSyntheticTrailingComment(substitute, SyntaxKind.MultiLineCommentTrivia, ` ${safeMultiLineComment(getTextOfNode(originalNode))} `);
33763373
}
3377-
33783374
return substitute;
33793375
}
33803376

tests/baselines/reference/amdModuleConstEnumUsage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ define(["require", "exports"], function (require, exports) {
3434
function User() {
3535
}
3636
User.prototype.method = function (input) {
37-
if (0 /* A */ === input) { }
37+
if (0 /* CharCode.A */ === input) { }
3838
};
3939
return User;
4040
}());

tests/baselines/reference/assignmentNonObjectTypeConstraints.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function foo(x) {
2424
var y = x; // Ok
2525
}
2626
foo(5);
27-
foo(0 /* A */);
27+
foo(0 /* E.A */);
2828
var A = /** @class */ (function () {
2929
function A() {
3030
}

tests/baselines/reference/blockScopedEnumVariablesUseBeforeDef.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ function foo1() {
1818
})(E || (E = {}));
1919
}
2020
function foo2() {
21-
return 0 /* A */;
21+
return 0 /* E.A */;
2222
}

tests/baselines/reference/blockScopedEnumVariablesUseBeforeDef_preserve.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function foo1() {
1818
})(E || (E = {}));
1919
}
2020
function foo2() {
21-
return 0 /* A */;
21+
return 0 /* E.A */;
2222
var E;
2323
(function (E) {
2424
E[E["A"] = 0] = "A";

tests/baselines/reference/constEnum3.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ f2('bar')
1414
//// [constEnum3.js]
1515
function f1(f) { }
1616
function f2(f) { }
17-
f1(0 /* foo */);
18-
f1(1 /* bar */);
17+
f1(0 /* TestType.foo */);
18+
f1(1 /* TestType.bar */);
1919
f2('foo');
2020
f2('bar');

tests/baselines/reference/constEnumExternalModule.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ define(["require", "exports"], function (require, exports) {
1919
define(["require", "exports"], function (require, exports) {
2020
"use strict";
2121
exports.__esModule = true;
22-
var v = 100 /* V */;
22+
var v = 100 /* A.V */;
2323
});

tests/baselines/reference/constEnumNamespaceReferenceCausesNoImport(isolatedmodules=false).js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ exports.fooFunc = fooFunc;
2929
exports.__esModule = true;
3030
function check(x) {
3131
switch (x) {
32-
case 0 /* Some */:
32+
case 0 /* Foo.ConstFooEnum.Some */:
3333
break;
3434
}
3535
}

tests/baselines/reference/constEnumNamespaceReferenceCausesNoImport2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ module.exports = Foo.ConstEnumOnlyModule;
4444
exports.__esModule = true;
4545
function check(x) {
4646
switch (x) {
47-
case 0 /* Some */:
47+
case 0 /* Foo.ConstFooEnum.Some */:
4848
break;
4949
}
5050
}

tests/baselines/reference/constEnumNoEmitReexport.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ exports.__esModule = true;
4747
//// [Usage1.js]
4848
"use strict";
4949
exports.__esModule = true;
50-
0 /* Foo */;
51-
0 /* Foo */;
50+
0 /* MyConstEnum1.Foo */;
51+
0 /* MyConstEnum2.Foo */;
5252
//// [Usage2.js]
5353
"use strict";
5454
exports.__esModule = true;
55-
0 /* Foo */;
55+
0 /* MyConstEnum.Foo */;
5656
//// [Usage3.js]
5757
"use strict";
5858
exports.__esModule = true;
59-
0 /* Foo */;
59+
0 /* MyConstEnum.Foo */;

0 commit comments

Comments
 (0)