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

Commit d2a11ef

Browse files
committed
remove unused jsxVersion
* jsx version check is conducted in compiler config side
1 parent eb57f47 commit d2a11ef

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

cli/reactjs_jsx_ppx_v3.ml

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,7 @@ let reactComponentSignatureTransform mapper signatures =
11111111
List.fold_right (transformComponentSignature mapper) signatures []
11121112
[@@raises Invalid_argument]
11131113

1114-
let transformJsxCall jsxVersion mapper callExpression callArguments attrs =
1114+
let transformJsxCall mapper callExpression callArguments attrs =
11151115
match callExpression.pexp_desc with
11161116
| Pexp_ident caller -> (
11171117
match caller with
@@ -1120,20 +1120,14 @@ let transformJsxCall jsxVersion mapper callExpression callArguments attrs =
11201120
(Invalid_argument
11211121
"JSX: `createElement` should be preceeded by a module name.")
11221122
(* Foo.createElement(~prop1=foo, ~prop2=bar, ~children=[], ()) *)
1123-
| {loc; txt = Ldot (modulePath, ("createElement" | "make"))} -> (
1124-
match !jsxVersion with
1125-
| None | Some 3 ->
1126-
transformUppercaseCall3 modulePath mapper loc attrs callExpression
1127-
callArguments
1128-
| Some _ -> raise (Invalid_argument "JSX: the JSX version must be 3"))
1123+
| {loc; txt = Ldot (modulePath, ("createElement" | "make"))} ->
1124+
transformUppercaseCall3 modulePath mapper loc attrs callExpression
1125+
callArguments
11291126
(* div(~prop1=foo, ~prop2=bar, ~children=[bla], ()) *)
11301127
(* turn that into
11311128
ReactDOMRe.createElement(~props=ReactDOMRe.props(~props1=foo, ~props2=bar, ()), [|bla|]) *)
1132-
| {loc; txt = Lident id} -> (
1133-
match !jsxVersion with
1134-
| None | Some 3 ->
1135-
transformLowercaseCall3 mapper loc attrs callExpression callArguments id
1136-
| Some _ -> raise (Invalid_argument "JSX: the JSX version must be 3"))
1129+
| {loc; txt = Lident id} ->
1130+
transformLowercaseCall3 mapper loc attrs callExpression callArguments id
11371131
| {txt = Ldot (_, anythingNotCreateElementOrMake)} ->
11381132
raise
11391133
(Invalid_argument
@@ -1165,7 +1159,7 @@ let structure nestedModules mapper structure =
11651159
@@ reactComponentTransform nestedModules mapper structures
11661160
[@@raises Invalid_argument]
11671161

1168-
let expr jsxVersion mapper expression =
1162+
let expr mapper expression =
11691163
match expression with
11701164
(* Does the function application have the @JSX attribute? *)
11711165
| {pexp_desc = Pexp_apply (callExpression, callArguments); pexp_attributes}
@@ -1179,8 +1173,7 @@ let expr jsxVersion mapper expression =
11791173
(* no JSX attribute *)
11801174
| [], _ -> default_mapper.expr mapper expression
11811175
| _, nonJSXAttributes ->
1182-
transformJsxCall jsxVersion mapper callExpression callArguments
1183-
nonJSXAttributes)
1176+
transformJsxCall mapper callExpression callArguments nonJSXAttributes)
11841177
(* is it a list with jsx attribute? Reason <>foo</> desugars to [@JSX][foo]*)
11851178
| {
11861179
pexp_desc =
@@ -1231,10 +1224,8 @@ let module_binding nestedModules mapper module_binding =
12311224

12321225
(* TODO: some line number might still be wrong *)
12331226
let jsxMapper nestedModules =
1234-
let jsxVersion = ref None in
12351227
let structure = structure nestedModules in
12361228
let module_binding = module_binding nestedModules in
1237-
let expr = expr jsxVersion in
12381229
{default_mapper with structure; expr; signature; module_binding}
12391230
[@@raises Invalid_argument, Failure]
12401231

0 commit comments

Comments
 (0)