Skip to content

Commit 9bc7efb

Browse files
committed
replace undefined with void 0
1 parent a2c648d commit 9bc7efb

File tree

311 files changed

+5793
-5780
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

311 files changed

+5793
-5780
lines changed

jscomp/core/js_dump.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ and expression_desc cxt ~(level:int) f x : cxt =
552552
| Null ->
553553
P.string f L.null; cxt
554554
| Undefined ->
555-
P.string f L.undefined; cxt
555+
P.string f "void 0"; cxt
556556
| Var v ->
557557
vident cxt f v
558558
| Bool b ->

jscomp/others/js_dict.ml

+4-3
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,12 @@ This function will return an invalid value ([undefined]) if [key] does not exist
3636
will not throw an error.
3737
*)
3838
external unsafeGet : 'a t -> key -> 'a = "" [@@bs.get_index]
39+
let (.!()) = unsafeGet
3940

4041
(** [get dict key] returns the value associated with [key] in [dict] *)
4142
let get (type u) (dict : u t) (k : key) : u option =
4243
if [%raw {|k in dict|}] then
43-
Some (unsafeGet dict k)
44+
Some dict.!(k)
4445
else None
4546

4647
(** [set dict key value] sets the value of [key] in [dict] to [value] *)
@@ -68,7 +69,7 @@ let entries dict =
6869
let values = unsafeCreate l in
6970
for i = 0 to l - 1 do
7071
let key = Js_array2.unsafe_get keys i in
71-
Js_array2.unsafe_set values i (key, unsafeGet dict key)
72+
Js_array2.unsafe_set values i (key, dict.!(key))
7273
done;
7374
values
7475

@@ -78,7 +79,7 @@ let values dict =
7879
let l = Js_array2.length keys in
7980
let values = unsafeCreate l in
8081
for i = 0 to l - 1 do
81-
Js_array2.unsafe_set values i (unsafeGet dict (Js_array2.unsafe_get keys i))
82+
Js_array2.unsafe_set values i dict.!(Js_array2.unsafe_get keys i)
8283
done;
8384
values
8485

jscomp/test/a_string_test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ var suites_001 = /* :: */[
2929
"split_non_empty",
3030
(function (param) {
3131
return /* Eq */Block.__(0, [
32-
Ext_string_test.split(undefined, "hihi", /* "i" */105),
32+
Ext_string_test.split(void 0, "hihi", /* "i" */105),
3333
/* :: */[
3434
"h",
3535
/* :: */[
@@ -76,7 +76,7 @@ var suites_001 = /* :: */[
7676
return /* Eq */Block.__(0, [
7777
List.filter((function (s) {
7878
return s !== "";
79-
}))(Ext_string_test.split_by(undefined, (function (x) {
79+
}))(Ext_string_test.split_by(void 0, (function (x) {
8080
if (x === /* " " */32) {
8181
return true;
8282
} else {

jscomp/test/alias_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function ff(param) {
1111
return "cool test hello worldnothello worldnothello";
1212
}
1313

14-
var a23 = ff(undefined);
14+
var a23 = ff(void 0);
1515

1616
var a15 = a10;
1717

jscomp/test/app_root_finder.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ function find_package_json(_dir) {
2121
};
2222
}
2323

24-
var match = typeof __dirname === "undefined" ? undefined : __dirname;
24+
var match = typeof __dirname === "undefined" ? void 0 : __dirname;
2525

26-
if (match !== undefined) {
26+
if (match !== void 0) {
2727
console.log(find_package_json(match));
2828
}
2929

jscomp/test/arity_infer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function f0(x) {
1616

1717
function f1(x) {
1818
throw Caml_builtin_exceptions.not_found;
19-
return Curry._1(undefined, x);
19+
return Curry._1(void 0, x);
2020
}
2121

2222
function f3(x) {

jscomp/test/array_subtle_test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@ eq("File \"array_subtle_test.ml\", line 29, characters 5-12", /* tuple */[
8181

8282
function f(v) {
8383
var match = v.pop();
84-
if (match !== undefined) {
84+
if (match !== void 0) {
8585
console.log("hi");
8686
} else {
8787
console.log("hi2");
8888
}
89-
console.log((v.pop(), undefined));
89+
console.log((v.pop(), void 0));
9090

9191
}
9292

jscomp/test/ast_js_mapper_poly_test.js

+15-15
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ function eqU(x, y) {
5858
}
5959

6060
function eqUOpt(x, y) {
61-
if (x !== undefined) {
62-
if (y !== undefined) {
61+
if (x !== void 0) {
62+
if (y !== void 0) {
6363
return x === y;
6464
} else {
6565
return false;
6666
}
6767
} else {
68-
return y === undefined;
68+
return y === void 0;
6969
}
7070
}
7171

@@ -75,7 +75,7 @@ eq("File \"ast_js_mapper_poly_test.ml\", line 26, characters 5-12", eqUOpt(uFrom
7575

7676
eq("File \"ast_js_mapper_poly_test.ml\", line 27, characters 5-12", eqUOpt(uFromJs("C"), /* C */67), true);
7777

78-
eq("File \"ast_js_mapper_poly_test.ml\", line 28, characters 5-12", eqUOpt(uFromJs("f"), undefined), true);
78+
eq("File \"ast_js_mapper_poly_test.ml\", line 28, characters 5-12", eqUOpt(uFromJs("f"), void 0), true);
7979

8080
eq("File \"ast_js_mapper_poly_test.ml\", line 29, characters 5-12", $$Array.map(uToJs, [
8181
/* D */68,
@@ -107,14 +107,14 @@ function eqV(x, y) {
107107
}
108108

109109
function eqVOpt(x, y) {
110-
if (x !== undefined) {
111-
if (y !== undefined) {
110+
if (x !== void 0) {
111+
if (y !== void 0) {
112112
return x === y;
113113
} else {
114114
return false;
115115
}
116116
} else {
117-
return y === undefined;
117+
return y === void 0;
118118
}
119119
}
120120

@@ -154,12 +154,12 @@ eq("File \"ast_js_mapper_poly_test.ml\", line 55, characters 5-12", $$Array.map(
154154
6
155155
]), [
156156
/* A0 */0,
157-
undefined,
158-
undefined,
157+
void 0,
158+
void 0,
159159
/* A1 */1,
160160
/* A2 */2,
161161
/* A3 */3,
162-
undefined
162+
void 0
163163
]);
164164

165165
function v1ToJs(param) {
@@ -199,14 +199,14 @@ eq("File \"ast_js_mapper_poly_test.ml\", line 69, characters 5-12", $$Array.map(
199199
5,
200200
6
201201
]), [
202-
undefined,
202+
void 0,
203203
/* B0 */0,
204204
/* B1 */1,
205205
/* B2 */2,
206206
/* B3 */3,
207207
/* B4 */4,
208208
/* B5 */5,
209-
undefined
209+
void 0
210210
]);
211211

212212
function v2ToJs(param) {
@@ -247,8 +247,8 @@ eq("File \"ast_js_mapper_poly_test.ml\", line 89, characters 5-12", $$Array.map(
247247
7,
248248
8
249249
]), $$Array.append($$Array.append([
250-
undefined,
251-
undefined
250+
void 0,
251+
void 0
252252
], $$Array.map((function (x) {
253253
return x;
254254
}), [
@@ -258,7 +258,7 @@ eq("File \"ast_js_mapper_poly_test.ml\", line 89, characters 5-12", $$Array.map(
258258
/* C3 */3,
259259
/* C4 */4,
260260
/* C5 */5
261-
])), [undefined]));
261+
])), [void 0]));
262262

263263
Mt.from_pair_suites("Ast_js_mapper_poly_test", suites.contents);
264264

jscomp/test/bdd.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ function random(param) {
335335
function random_vars(n) {
336336
var vars = Caml_array.caml_make_vect(n, false);
337337
for(var i = 0 ,i_finish = n - 1 | 0; i <= i_finish; ++i){
338-
Caml_array.caml_array_set(vars, i, random(undefined));
338+
Caml_array.caml_array_set(vars, i, random(void 0));
339339
}
340340
return vars;
341341
}
@@ -384,7 +384,7 @@ function main(param) {
384384
];
385385
}
386386

387-
main(undefined);
387+
main(void 0);
388388

389389
var initSize_1 = 8191;
390390

jscomp/test/belt_internal_test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33

44
function treeHeight(n) {
5-
if (n !== undefined) {
5+
if (n !== void 0) {
66
return n.height;
77
} else {
88
return 0;
99
}
1010
}
1111

1212
function copy(n) {
13-
if (n === undefined) {
13+
if (n === void 0) {
1414
return n;
1515
}
1616
var match = n;

jscomp/test/bench.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function f2(param) {
5959

6060
}
6161

62-
f2(undefined);
62+
f2(void 0);
6363

6464
exports.map = map;
6565
exports.init = init;

jscomp/test/big_polyvar_test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1215,14 +1215,14 @@ function tFromJs(param) {
12151215
}
12161216

12171217
function eq(x, y) {
1218-
if (x !== undefined) {
1219-
if (y !== undefined) {
1218+
if (x !== void 0) {
1219+
if (y !== void 0) {
12201220
return x === y;
12211221
} else {
12221222
return false;
12231223
}
12241224
} else {
1225-
return y === undefined;
1225+
return y === void 0;
12261226
}
12271227
}
12281228

@@ -7826,7 +7826,7 @@ if (!eq(tFromJs("variant299"), /* variant299 */34947885)) {
78267826
];
78277827
}
78287828

7829-
if (!eq(tFromJs("xx"), undefined)) {
7829+
if (!eq(tFromJs("xx"), void 0)) {
78307830
throw [
78317831
Caml_builtin_exceptions.assert_failure,
78327832
/* tuple */[

jscomp/test/bs_MapInt_test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ function test(param) {
1616
m = Belt_MapInt.set(m, i, i);
1717
}
1818
for(var i$1 = 0; i$1 <= 999999; ++i$1){
19-
should(Belt_MapInt.get(m, i$1) !== undefined);
19+
should(Belt_MapInt.get(m, i$1) !== void 0);
2020
}
2121
for(var i$2 = 0; i$2 <= 999999; ++i$2){
2222
m = Belt_MapInt.remove(m, i$2);
2323
}
2424
return should(Belt_MapInt.isEmpty(m));
2525
}
2626

27-
test(undefined);
27+
test(void 0);
2828

2929
var M = /* alias */0;
3030

jscomp/test/bs_abstract_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function uff2(f) {
3838

3939
function uff3(f) {
4040
var match = f.yyyy2;
41-
if (match !== undefined) {
41+
if (match !== void 0) {
4242
return Curry._1(match, 0);
4343
} else {
4444
return 0;

jscomp/test/bs_array_test.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ eq("File \"bs_array_test.ml\", line 25, characters 5-12", /* tuple */[
7676
], /* tuple */[
7777
1,
7878
2,
79-
undefined,
80-
undefined,
81-
undefined
79+
void 0,
80+
void 0,
81+
void 0
8282
]);
8383

8484
$$throw("File \"bs_array_test.ml\", line 28, characters 8-15", (function (param) {
@@ -1566,7 +1566,7 @@ eq("File \"bs_array_test.ml\", line 335, characters 5-12", Belt_Array.getBy([
15661566
3
15671567
], (function (x) {
15681568
return x > 3;
1569-
})), undefined);
1569+
})), void 0);
15701570

15711571
eq("File \"bs_array_test.ml\", line 338, characters 5-12", Belt_Array.getIndexBy([
15721572
1,
@@ -1582,7 +1582,7 @@ eq("File \"bs_array_test.ml\", line 339, characters 5-12", Belt_Array.getIndexBy
15821582
3
15831583
], (function (x) {
15841584
return x > 3;
1585-
})), undefined);
1585+
})), void 0);
15861586

15871587
Mt.from_pair_suites("File \"bs_array_test.ml\", line 341, characters 23-30", suites.contents);
15881588

jscomp/test/bs_auto_uncurry.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ function f_01(param) {
5050

5151
function f_02(xs) {
5252
return hi((function () {
53-
xs.contents = undefined;
53+
xs.contents = void 0;
5454
console.log("x");
5555

5656
}));
5757
}
5858

5959
function f_03(xs, u) {
6060
return hi((function () {
61-
return Curry._1(u, undefined);
61+
return Curry._1(u, void 0);
6262
}));
6363
}
6464

@@ -121,7 +121,7 @@ function unit_magic(param) {
121121
return 3;
122122
}
123123

124-
var f_unit_magic = unit_magic(undefined);
124+
var f_unit_magic = unit_magic(void 0);
125125

126126
function hh(xs) {
127127
return (function (param) {

jscomp/test/bs_auto_uncurry_test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -40,24 +40,24 @@ var xs = {
4040

4141
hi((function () {
4242
xs.contents = /* :: */[
43-
undefined,
43+
void 0,
4444
xs.contents
4545
];
4646

4747
}));
4848

4949
hi((function () {
5050
xs.contents = /* :: */[
51-
undefined,
51+
void 0,
5252
xs.contents
5353
];
5454

5555
}));
5656

5757
eq("File \"bs_auto_uncurry_test.ml\", line 27, characters 7-14", xs.contents, /* :: */[
58-
undefined,
58+
void 0,
5959
/* :: */[
60-
undefined,
60+
void 0,
6161
/* [] */0
6262
]
6363
]);

jscomp/test/bs_float_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ eq("File \"bs_float_test.ml\", line 30, characters 5-12", Belt_Float.fromString(
6969

7070
eq("File \"bs_float_test.ml\", line 31, characters 5-12", Belt_Float.fromString("-1.7"), -1.7);
7171

72-
eq("File \"bs_float_test.ml\", line 32, characters 5-12", Belt_Float.fromString("not a float"), undefined);
72+
eq("File \"bs_float_test.ml\", line 32, characters 5-12", Belt_Float.fromString("not a float"), void 0);
7373

7474
eq("File \"bs_float_test.ml\", line 35, characters 5-12", String(1.0), "1");
7575

0 commit comments

Comments
 (0)