Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit 94de392

Browse files
author
Iwan
committed
Tweak %bs.obj vs %obj
1 parent d775ea6 commit 94de392

File tree

10 files changed

+25
-21
lines changed

10 files changed

+25
-21
lines changed

src/res_comments_table.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,7 @@ let rec walkStructure s t comments =
879879
attach t.trailing expr2.pexp_loc trailing
880880
)
881881
| Pexp_extension (
882-
{txt = "bs.obj"},
882+
{txt = "bs.obj" | "obj"},
883883
PStr [{
884884
pstr_desc = Pstr_eval({pexp_desc = Pexp_record (rows, _)}, [])
885885
}]

src/res_core.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2919,7 +2919,7 @@ and parseRecordExprWithStringKeys ~startPos firstRow p =
29192919
Ast_helper.Exp.record ~loc rows None
29202920
) in
29212921
Ast_helper.Exp.extension ~loc
2922-
(Location.mkloc "bs.obj" loc, Parsetree.PStr [recordStrExpr])
2922+
(Location.mkloc "obj" loc, Parsetree.PStr [recordStrExpr])
29232923

29242924
and parseRecordExpr ~startPos ?(spread=None) rows p =
29252925
let exprs =

src/res_js_ffi.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ let importDescr ~attrs ~scope ~importSpec ~loc = {
3939
}
4040

4141
let toParsetree importDescr =
42-
let bsVal = (Location.mknoloc "bs.val", Parsetree.PStr []) in
42+
let bsVal = (Location.mknoloc "val", Parsetree.PStr []) in
4343
let attrs = match importDescr.jid_scope with
4444
| Global -> [bsVal]
4545
(* @genType.import("./MyMath"),
@@ -63,7 +63,7 @@ let toParsetree importDescr =
6363
Ast_helper.Str.eval expr
6464
in
6565
let bsScope = (
66-
Location.mknoloc "bs.scope",
66+
Location.mknoloc "scope",
6767
Parsetree. PStr [structureItem]
6868
) in
6969
[bsVal; bsScope]
@@ -113,4 +113,4 @@ let toParsetree importDescr =
113113
let jsFfiAttr = (Location.mknoloc "ns.jsFfi", Parsetree.PStr []) in
114114
Ast_helper.Mod.structure ~loc:importDescr.jid_loc valueDescrs
115115
|> Ast_helper.Incl.mk ~attrs:[jsFfiAttr] ~loc:importDescr.jid_loc
116-
|> Ast_helper.Str.include_ ~loc:importDescr.jid_loc
116+
|> Ast_helper.Str.include_ ~loc:importDescr.jid_loc

src/res_parsetree_viewer.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ let isHuggableExpression expr =
193193
| Pexp_tuple _
194194
| Pexp_constant (Pconst_string (_, Some _))
195195
| Pexp_construct ({txt = Longident.Lident ("::" | "[]")}, _)
196-
| Pexp_extension ({txt = "bs.obj"}, _)
196+
| Pexp_extension ({txt = "bs.obj" | "obj"}, _)
197197
| Pexp_record _ -> true
198198
| _ when isBlockExpr expr -> true
199199
| _ when isBracedExpr expr -> true
@@ -205,7 +205,7 @@ let isHuggableRhs expr =
205205
| Pexp_array _
206206
| Pexp_tuple _
207207
| Pexp_construct ({txt = Longident.Lident ("::" | "[]")}, _)
208-
| Pexp_extension ({txt = "bs.obj"}, _)
208+
| Pexp_extension ({txt = "bs.obj" | "obj"}, _)
209209
| Pexp_record _ -> true
210210
| _ when isBracedExpr expr -> true
211211
| _ -> false

src/res_printer.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2709,7 +2709,7 @@ and printExpression (e : Parsetree.expression) cmtTbl =
27092709
| Pexp_extension extension ->
27102710
begin match extension with
27112711
| (
2712-
{txt = "bs.obj"},
2712+
{txt = "bs.obj" | "obj"},
27132713
PStr [{
27142714
pstr_loc = loc;
27152715
pstr_desc = Pstr_eval({pexp_desc = Pexp_record (rows, _)}, [])

tests/conversion/reason/__snapshots__/render.spec.js.snap

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,6 +1086,9 @@ exports[`jsObject.re 1`] = `
10861086
"let component = props[\\"Component\\"]
10871087
10881088
let element = props[\\"element\\"]
1089+
1090+
let y = {\\"age\\": 30}
1091+
let y = {\\"age\\": 30, \\"name\\": \\"steve\\"}
10891092
"
10901093
`;
10911094

tests/conversion/reason/jsObject.re

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
let component = props##"Component"
22

33
let element = props##element
4+
5+
let y = {"age": 30}
6+
let y = {"age": 30, "name": "steve"}

tests/parsing/grammar/expressions/__snapshots__/parse.spec.js.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,10 +281,10 @@ let x = ((let a = 1 in let b = 2 in a + b)[@ns.braces ])
281281
`;
282282

283283
exports[`bsObject.js 1`] = `
284-
"let x = [%bs.obj { age = 30 }]
285-
let y = [%bs.obj { age = 30 }]
286-
let y = [%bs.obj { age = 30; name = \\"steve\\" }]
287-
let y = [%bs.obj { age = 30; name = \\"steve\\" }]
284+
"let x = [%obj { age = 30 }]
285+
let y = [%obj { age = 30 }]
286+
let y = [%obj { age = 30; name = \\"steve\\" }]
287+
let y = [%obj { age = 30; name = \\"steve\\" }]
288288
let x = ((\\"age\\")[@ns.braces ])
289289
let x = ((\\"age\\".(0))[@ns.braces ])
290290
let x = ((\\"age\\" |. Js.log)[@ns.braces ])

tests/parsing/grammar/structure/__snapshots__/parse.spec.js.snap

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,27 +62,25 @@ exports[`jsFfiSugar.js 1`] = `
6262
"include
6363
struct
6464
external setTimeout : (unit -> unit) -> unit -> float = \\"setTimeout\\"
65-
[@@bs.val ]
65+
[@@val ]
6666
end[@@ns.jsFfi ]
6767
include
6868
struct
69-
external timeout : (unit -> unit) -> unit -> float = \\"setTimeout\\"
70-
[@@bs.val ]
69+
external timeout : (unit -> unit) -> unit -> float = \\"setTimeout\\"[@@val ]
7170
end[@@ns.jsFfi ]
7271
include
7372
struct
7473
external setTimeout : (unit -> unit) -> unit -> float = \\"setTimeout\\"
75-
[@@bs.val ]
76-
external clearTimeout : float -> unit = \\"clearTimeout\\"[@@bs.val ]
74+
[@@val ]
75+
external clearTimeout : float -> unit = \\"clearTimeout\\"[@@val ]
7776
end[@@ns.jsFfi ]
7877
include
7978
struct
80-
external random : unit -> float = \\"random\\"[@@bs.val ][@@bs.scope \\"Math\\"]
79+
external random : unit -> float = \\"random\\"[@@val ][@@scope \\"Math\\"]
8180
end[@@ns.jsFfi ]
8281
include
8382
struct
84-
external href : string = \\"href\\"[@@bs.val ][@@bs.scope
85-
(\\"window\\", \\"location\\")]
83+
external href : string = \\"href\\"[@@val ][@@scope (\\"window\\", \\"location\\")]
8684
end[@@ns.jsFfi ]
8785
include
8886
struct

tests/printer/ffi/__snapshots__/render.spec.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ include {
3636
3737
@ns.jsFfi
3838
include {
39-
@bs.val external document: Dom.document = \\"document\\"
39+
@val external document: Dom.document = \\"document\\"
4040
}
4141
"
4242
`;

0 commit comments

Comments
 (0)