Skip to content

Commit aa0b0f4

Browse files
brad4dcopybara-github
authored andcommitted
Add unit test for collapse properties issue
TS 5.2 starts outputing code in a shape that causes a bad property collapse. PiperOrigin-RevId: 563648863
1 parent dc5ed73 commit aa0b0f4

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

test/com/google/javascript/jscomp/InlineAndCollapsePropertiesTest.java

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,49 @@ public void setUp() throws Exception {
6969
disableCompareJsDoc();
7070
}
7171

72+
@Test
73+
public void testTs52OutputChange() {
74+
test(
75+
srcs(
76+
lines(
77+
"", //
78+
"var alias;",
79+
"var module$exports$C = class {",
80+
" method1() {",
81+
" return alias.staticPropOnC;",
82+
" }",
83+
" method2() {",
84+
" return alias.staticPropOnAlias;",
85+
" }",
86+
"}",
87+
"alias = module$exports$C;",
88+
"(() => {",
89+
" alias.staticPropOnAlias = 1",
90+
"})();",
91+
"module$exports$C.staticPropOnC = 2;",
92+
"")),
93+
expected(
94+
lines(
95+
"", //
96+
"var alias;",
97+
"var module$exports$C = class {",
98+
" method1() {",
99+
" return alias.staticPropOnC;",
100+
" }",
101+
" method2() {",
102+
" return alias.staticPropOnAlias;",
103+
" }",
104+
"}",
105+
"alias = module$exports$C;",
106+
"(() => {",
107+
" alias.staticPropOnAlias = 1",
108+
"})();",
109+
// TODO : b/299055739 - bad collapse
110+
"var module$exports$C$staticPropOnC = 2;",
111+
"",
112+
"")));
113+
}
114+
72115
@Test
73116
public void testDoNotCollapseDeletedProperty() {
74117
testSame(

0 commit comments

Comments
 (0)