Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions jscomp/syntax/src/jsx_v4.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1258,7 +1258,6 @@ let transformSignatureItem ~config item =
let pval_type = Jsx_common.extractUncurried pval_type in
check_string_int_attribute_iter.signature_item
check_string_int_attribute_iter item;
let hasForwardRef = ref false in
let coreTypeOfAttr = Jsx_common.coreTypeOfAttrs pval_attributes in
let typVarsOfCoreType =
coreTypeOfAttr
Expand All @@ -1277,9 +1276,7 @@ let transformSignatureItem ~config item =
(Nolabel, {ptyp_desc = Ptyp_constr ({txt = Lident "unit"}, _)}, rest)
->
getPropTypes types rest
| Ptyp_arrow (Nolabel, _type, rest) ->
hasForwardRef := true;
getPropTypes types rest
| Ptyp_arrow (Nolabel, _type, rest) -> getPropTypes types rest
| Ptyp_arrow (name, ({ptyp_attributes = attrs} as type_), returnValue)
when isOptional name || isLabelled name ->
(returnValue, (name, attrs, returnValue.ptyp_loc, type_) :: types)
Expand All @@ -1299,12 +1296,7 @@ let transformSignatureItem ~config item =
in
let propsRecordType =
makePropsRecordTypeSig ~coreTypeOfAttr ~typVarsOfCoreType "props"
psig_loc
((* If there is Nolabel arg, regard the type as ref in forwardRef *)
(if !hasForwardRef then
[(true, "ref", [], Location.none, refTypeVar Location.none)]
else [])
@ namedTypeList)
psig_loc namedTypeList
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like I implemented unnecessary handling in the initial version of JSX4. This handling is unnecessary because we typically use the labeled ~ref in the interface of React.forwardRef implementations. Please see the tests I've added. 34d17b7

in
(* can't be an arrow because it will defensively uncurry *)
let newExternalType =
Expand Down