Skip to content

Commit 8b0477e

Browse files
authored
Remove deprecated Js modules (#8531)
1 parent 21e6382 commit 8b0477e

1,031 files changed

Lines changed: 3987 additions & 32232 deletions

File tree

Some content is hidden

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

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
#### :boom: Breaking Change
1616

17+
- Remove the deprecated `Js` namespace and its runtime modules. https://github.com/rescript-lang/rescript/pull/8531
18+
1719
#### :eyeglasses: Spec Compliance
1820

1921
#### :rocket: New Feature

analysis/reanalyze/src/exn_lib.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ let raises_lib_table : (Name.t, Exceptions.t) Hashtbl.t =
195195
("Error", stdlib_error);
196196
("Exn", stdlib_exn);
197197
("JsError", stdlib_js_error);
198-
("Js.Json", [("parseExn", [js_exn])]);
199198
("JSON", stdlib_json);
200199
("Json_decode", bs_json);
201200
("Json.Decode", bs_json);

analysis/src/completion_front_end.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,13 +328,13 @@ let complete_pipe_chain ~(in_jsx_context : bool) (exp : Parsetree.expression) =
328328
(* Complete the end of pipe chains by reconstructing the pipe chain as a single pipe,
329329
so it can be completed.
330330
Example:
331-
someArray->Js.Array2.filter(v => v > 10)->Js.Array2.map(v => v + 2)->
331+
someArray->Array.filter(v => v > 10)->Array.map(v => v + 2)->
332332
will complete as:
333-
Js.Array2.map(someArray->Js.Array2.filter(v => v > 10), v => v + 2)->
333+
Array.map(someArray->Array.filter(v => v > 10), v => v + 2)->
334334
*)
335335
match exp.pexp_desc with
336336
(* When the left side of the pipe we're completing is a function application.
337-
Example: someArray->Js.Array2.map(v => v + 2)-> *)
337+
Example: someArray->Array.map(v => v + 2)-> *)
338338
| Pexp_apply
339339
{
340340
funct = {pexp_desc = Pexp_ident {txt = Lident "->"}};

compiler/core/design.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
- printing
66

77
```ocaml
8-
Js.log true
8+
Console.log true
99
```
1010

1111
- pattern match

compiler/core/destruct_exn.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ However it does not prevent things like
1111

1212
```ocaml
1313
destruct v begin fun exn ->
14-
Js.log exn ;
14+
Console.log exn ;
1515
match exn with
1616
| ..
1717
| ..
@@ -44,7 +44,7 @@ Another proposal is
4444
match%exn computation with
4545
| A ..
4646
| B ..
47-
| Js.NonCamlOpenVariant ..
47+
| JsExn ..
4848
| v -> ..
4949
```
5050

@@ -53,7 +53,7 @@ Here we pack the data `v`
5353
==>
5454
```
5555
56-
match (Js_enx.internalTOOCamlException compuation) with
56+
match (Primitive_exceptions.internalToException computation) with
5757
| A ..
5858
| B
5959
| exception .. )
@@ -62,7 +62,7 @@ match (Js_enx.internalTOOCamlException compuation) with
6262
The same problem is
6363

6464
```
65-
match (Js_enx.internalTOOCamlException compuation) with
65+
match (Primitive_exceptions.internalToException computation) with
6666
| _ -> ..
6767
```
6868

@@ -76,6 +76,6 @@ Another very similar proposal would be
7676
```ocaml
7777
fun[@bs:exn] e ->
7878
match e with
79-
| Js.Exn.Error ..
79+
| JsExn ..
8080
| ..
81-
```
81+
```

compiler/core/lam_convert.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ let lam_extension_id loc (head : Lam.t) =
3737
]}
3838
we approximate that if [id] is destructed or not.
3939
If it is destructed, we need pack it in case it is JS exception.
40-
The packing is called Js.Exn.internalTOOCamlException, which is a nop for OCaml exception,
40+
The packing is called Primitive_exceptions.internalToException, which is a nop for OCaml exception,
4141
but will wrap as (Error e) when it is an JS exception.
4242
4343
{[
4444
try .. with
4545
| A (x,y) ->
46-
| Js.Error ..
46+
| Exn.Error ..
4747
]}
4848
4949
Without such wrapping, the code above would raise

compiler/core/outcome_printer_ns.ml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,6 @@ let ps = Format.pp_print_string
2727
let out_ident ppf s =
2828
ps ppf
2929
(match s with
30-
| "Js_null" -> "Js.Null"
31-
| "Js_undefined" -> "Js.Undefined"
32-
| "Js_null_undefined" -> "Js.Nullable"
33-
| "Js_exn" -> "Js.Exn"
34-
| "Js_array" -> "Js.Array"
35-
| "Js_string" -> "Js.String"
36-
| "Js_re" -> "Js.Re"
37-
| "Js_promise" -> "Js.Promise"
38-
| "Js_date" -> "Js.Date"
39-
| "Js_dict" -> "Js.Dict"
40-
| "Js_global" -> "Js.Global"
41-
| "Js_json" -> "Js.Json"
42-
| "Js_math" -> "Js.Math"
43-
| "Js_obj" -> "Js.Obj"
44-
| "Js_typed_array" -> "Js.Typed_array"
45-
| "Js_types" -> "Js.Types"
46-
| "Js_float" -> "Js.Float"
47-
| "Js_int" -> "Js.Int"
48-
| "Js_option" -> "Js.Option"
49-
| "Js_result" -> "Js.Result"
5030
(* Belt_libs *)
5131
| "Belt_Id" -> "Belt.Id"
5232
| "Belt_Array" -> "Belt.Array"

compiler/ext/primitive_modules.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,6 @@ let curry = "Primitive_curry"
5252

5353
let util = "Primitive_util"
5454

55+
let js_extern = "Primitive_js_extern"
56+
5557
let pervasives = "Pervasives"

compiler/frontend/ast_core_type.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ val from_labels : loc:Location.t -> int -> string Asttypes.loc list -> t
3434
(** return a function type
3535
[from_labels ~loc tyvars labels]
3636
example output:
37-
{[x:'a0 -> y:'a1 -> < x :'a0 ;y :'a1 > Js.t]}
37+
{[x:'a0 -> y:'a1 -> < x :'a0 ;y :'a1 >]}
3838
*)
3939

4040
val make_obj : loc:Location.t -> Parsetree.object_field list -> t

compiler/frontend/ast_exp_handle_external.ml

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -22,50 +22,6 @@
2222
* along with this program; if not, write to the Free Software
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2424

25-
(**
26-
{[
27-
Js.undefinedToOption
28-
(if Js.typeof x = "undefined" then undefined
29-
else x )
30-
31-
]}
32-
33-
@deprecated
34-
*)
35-
let handle_external loc (x : string) : Parsetree.expression =
36-
let raw_exp : Ast_exp.t =
37-
let str_exp =
38-
Ast_compatible.const_exp_string ~loc x ~delimiter:Ext_string.empty
39-
in
40-
{
41-
str_exp with
42-
pexp_desc =
43-
Ast_external_mk.local_external_apply loc ~pval_prim:["#raw_expr"]
44-
~pval_type:
45-
(Ast_helper.Typ.arrows
46-
[{attrs = []; lbl = Nolabel; typ = Ast_helper.Typ.any ()}]
47-
(Ast_helper.Typ.any ()))
48-
[str_exp];
49-
}
50-
in
51-
let empty =
52-
(* FIXME: the empty delimiter does not make sense*)
53-
Ast_helper.Exp.ident ~loc
54-
{txt = Ldot (Ldot (Lident "Js", "Undefined"), "empty"); loc}
55-
in
56-
let undefined_typeof =
57-
Ast_helper.Exp.ident {loc; txt = Ldot (Lident "Js", "undefinedToOption")}
58-
in
59-
let typeof = Ast_helper.Exp.ident {loc; txt = Ldot (Lident "Js", "typeof")} in
60-
61-
Ast_compatible.app1 ~loc undefined_typeof
62-
(Ast_helper.Exp.ifthenelse ~loc
63-
(Ast_compatible.app2 ~loc
64-
(Ast_helper.Exp.ident ~loc {loc; txt = Lident "=="})
65-
(Ast_compatible.app1 ~loc typeof raw_exp)
66-
(Ast_compatible.const_exp_string ~loc "undefined"))
67-
empty (Some raw_exp))
68-
6925
let handle_debugger loc (payload : Ast_payload.t) =
7026
match payload with
7127
| PStr [] ->

0 commit comments

Comments
 (0)