10000 remove undefined initialization. Closes #869 · terser/terser@36349ec · GitHub
[go: up one dir, main page]

Skip to content

Commit 36349ec

Browse files
remove undefined initialization. Closes #869
1 parent 73e6536 commit 36349ec

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

lib/compress/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5085,6 +5085,17 @@ def_optimize(AST_Definitions, function(self) {
50855085
return self;
50865086
});
50875087

5088+
def_optimize(AST_VarDef, function(self) {
5089+
if (
5090+
self.name instanceof AST_SymbolLet
5091+
&& self.value != null
5092+
&& is_undefined(self.value)
5093+
) {
5094+
self.value = null;
5095+
}
5096+
return self;
5097+
});
5098+
50885099
def_optimize(AST_Import, function(self) {
50895100
return self;
50905101
});

test/compress/block-scope.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@ do_not_hoist_let: {
3131
}
3232
}
3333

34+
drop_undefined_vardef: {
35+
input: {
36+
let x = undefined;
37+
const y = undefined;
38+
}
39+
expect: {
40+
let x;
41+
const y = void 0;
42+
}
43+
}
44+
3445
do_not_remove_anon_blocks_if_they_have_decls: {
3546
input: {
3647
function x() {

0 commit comments

Comments
 (0)
0