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

Commit ddf2640

Browse files
IwanKaramazowMaxim
and
Maxim
authored
Revert "jsx: allow locally abstract types and type constraints on @react.component definitions (#487)" (#488)
This reverts commit fab78d4. Co-authored-by: Maxim <mvalcke@hubspot.com>
1 parent fab78d4 commit ddf2640

File tree

5 files changed

+3
-26
lines changed

5 files changed

+3
-26
lines changed

src/reactjs_jsx_ppx_v3.ml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,9 @@ let otherAttrsPure (loc, _) = loc.txt <> "react.component"
9393
let hasAttrOnBinding { pvb_attributes } = find_opt hasAttr pvb_attributes <> None
9494

9595
(* Finds the name of the variable the binding is assigned to, otherwise raises Invalid_argument *)
96-
let rec getFnName binding =
96+
let getFnName binding =
9797
match binding with
98-
| { ppat_desc = Ppat_var { txt } } -> txt
99-
| { ppat_desc = Ppat_constraint (pat, _) } -> getFnName pat
98+
| { pvb_pat = { ppat_desc = Ppat_var { txt } } } -> txt
10099
| _ -> raise (Invalid_argument "react.component calls cannot be destructured.")
101100
[@@raises Invalid_argument]
102101

@@ -488,7 +487,7 @@ let jsxMapper () =
488487
let bindingLoc = binding.pvb_loc in
489488
let bindingPatLoc = binding.pvb_pat.ppat_loc in
490489
let binding = { binding with pvb_pat = { binding.pvb_pat with ppat_loc = emptyLoc }; pvb_loc = emptyLoc } in
491-
let fnName = getFnName binding.pvb_pat in
490+
let fnName = getFnName binding in
492491
let internalFnName = fnName ^ "$Internal" in
493492
let fullModuleName = makeModuleName fileName !nestedModules fnName in
494493
let modifiedBindingOld binding =
@@ -507,10 +506,6 @@ let jsxMapper () =
507506
spelunkForFunExpression innerFunctionExpression
508507
| { pexp_desc = Pexp_sequence (_wrapperExpression, innerFunctionExpression) } ->
509508
spelunkForFunExpression innerFunctionExpression
510-
| { pexp_desc = Pexp_newtype (_label, innerFunctionExpression) } ->
511-
spelunkForFunExpression innerFunctionExpression
512-
| { pexp_desc = Pexp_constraint (innerFunctionExpression, _typ) } ->
513-
spelunkForFunExpression innerFunctionExpression
514509
| _ ->
515510
raise
516511
(Invalid_argument

tests/ppx/react/expected/newtype.res.txt

Lines changed: 0 additions & 6 deletions
This file was deleted.

tests/ppx/react/expected/typeConstraint.res.txt

Lines changed: 0 additions & 8 deletions
This file was deleted.

tests/ppx/react/newtype.res

Lines changed: 0 additions & 2 deletions
This file was deleted.

tests/ppx/react/typeConstraint.res

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)