Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 4 additions & 3 deletions jscomp/syntax/reactjs_jsx_ppx.cppo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -640,10 +640,11 @@ let jsxMapper () =
| _ -> types
in

let argToConcreteType types (name, _loc, type_) = match name with
| name when isLabelled name || isOptional name ->
let argToConcreteType types (name, loc, type_) = match name with
| name when isLabelled name ->
(getLabel name, [], type_) :: types
(* return value *)
| name when isOptional name ->
(getLabel name, [], Typ.constr ~loc {loc; txt=optionIdent} [type_]) :: types
| _ -> types
in

Expand Down
1 change: 1 addition & 0 deletions jscomp/test/build.ninja
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ build test/gpr_3209_test.cmi test/gpr_3209_test.cmj : cc test/gpr_3209_test.ml |
build test/gpr_3492_test.cmi test/gpr_3492_test.cmj : cc test/gpr_3492_test.ml | test/mt.cmj $stdlib
build test/gpr_3502_test.cmi test/gpr_3502_test.cmj : cc test/gpr_3502_test.ml | $stdlib
build test/gpr_3519_test.cmi test/gpr_3519_test.cmj : cc test/gpr_3519_test.ml | $stdlib
build test/gpr_3519_jsx_test.cmi test/gpr_3519_jsx_test.cmj : cc test/gpr_3519_jsx_test.ml | $stdlib
build test/gpr_3536_test.cmi test/gpr_3536_test.cmj : cc test/gpr_3536_test.ml | test/mt.cmj $stdlib
build test/gpr_3546_test.cmi test/gpr_3546_test.cmj : cc test/gpr_3546_test.ml | $stdlib
build test/gpr_3548_test.cmi test/gpr_3548_test.cmj : cc test/gpr_3548_test.ml | $stdlib
Expand Down
11 changes: 11 additions & 0 deletions jscomp/test/gpr_3519_jsx_test.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module React = struct
type element = unit
let null = ()
end

module Foo :
sig
val make : ?htmlAttributes:float array -> unit -> React.element[@@react.component
]
end =
struct let make ?htmlAttributes:_ () = React.null[@@react.component ] end
70 changes: 36 additions & 34 deletions lib/4.06.1/bsdep.ml
Original file line number Diff line number Diff line change
Expand Up @@ -47177,10 +47177,11 @@ let jsxMapper () =
| _ -> types
in

let argToConcreteType types (name, _loc, type_) = match name with
| name when isLabelled name || isOptional name ->
let argToConcreteType types (name, loc, type_) = match name with
| name when isLabelled name ->
(getLabel name, [], type_) :: types
(* return value *)
| name when isOptional name ->
(getLabel name, [], Typ.constr ~loc {loc; txt=optionIdent} [type_]) :: types
| _ -> types
in

Expand All @@ -47203,10 +47204,10 @@ let jsxMapper () =
| Ptyp_arrow (name, type_, ({ptyp_desc = Ptyp_arrow _} as rest)) when isLabelled name || isOptional name ->
getPropTypes ((name, ptyp_loc, type_)::types) rest

# 669 "syntax/reactjs_jsx_ppx.cppo.ml"
# 670 "syntax/reactjs_jsx_ppx.cppo.ml"
| Ptyp_arrow (Nolabel, _type, rest) ->

# 673 "syntax/reactjs_jsx_ppx.cppo.ml"
# 674 "syntax/reactjs_jsx_ppx.cppo.ml"
getPropTypes types rest
| Ptyp_arrow (name, type_, returnValue) when isLabelled name || isOptional name ->
(returnValue, (name, returnValue.ptyp_loc, type_)::types)
Expand Down Expand Up @@ -47268,10 +47269,10 @@ let jsxMapper () =
((fun expressionDesc -> {expression with pexp_desc = Pexp_let (recursive, vbs, wrapExpression expressionDesc)}), realReturnExpression)
(* let make = React.forwardRef((~prop) => ...) *)

# 734 "syntax/reactjs_jsx_ppx.cppo.ml"
# 735 "syntax/reactjs_jsx_ppx.cppo.ml"
| { pexp_desc = Pexp_apply (wrapperExpression, [(Nolabel, innerFunctionExpression)]) } ->

# 738 "syntax/reactjs_jsx_ppx.cppo.ml"
# 739 "syntax/reactjs_jsx_ppx.cppo.ml"
let (wrapExpression, realReturnExpression) = spelunkForFunExpression innerFunctionExpression in
((fun expressionDesc -> {
expression with pexp_desc =
Expand Down Expand Up @@ -47414,10 +47415,10 @@ let jsxMapper () =
| Ptyp_arrow (name, type_, ({ptyp_desc = Ptyp_arrow _} as rest)) when isOptional name || isLabelled name ->
getPropTypes ((name, ptyp_loc, type_)::types) rest

# 880 "syntax/reactjs_jsx_ppx.cppo.ml"
# 881 "syntax/reactjs_jsx_ppx.cppo.ml"
| Ptyp_arrow (Nolabel, _type, rest) ->

# 884 "syntax/reactjs_jsx_ppx.cppo.ml"
# 885 "syntax/reactjs_jsx_ppx.cppo.ml"
getPropTypes types rest
| Ptyp_arrow (name, type_, returnValue) when isOptional name || isLabelled name ->
(returnValue, (name, returnValue.ptyp_loc, type_)::types)
Expand Down Expand Up @@ -47465,11 +47466,11 @@ let jsxMapper () =
| {loc; txt = Ldot (modulePath, ("createElement" | "make"))} ->
(match !jsxVersion with

# 931 "syntax/reactjs_jsx_ppx.cppo.ml"
# 932 "syntax/reactjs_jsx_ppx.cppo.ml"
| None
| Some 2 -> transformUppercaseCall modulePath mapper loc attrs callExpression callArguments

# 937 "syntax/reactjs_jsx_ppx.cppo.ml"
# 938 "syntax/reactjs_jsx_ppx.cppo.ml"
| Some 3 -> transformUppercaseCall3 modulePath mapper loc attrs callExpression callArguments
| Some _ -> raise (Invalid_argument "JSX: the JSX version must be 2 or 3"))

Expand All @@ -47479,11 +47480,11 @@ let jsxMapper () =
| {loc; txt = Lident id} ->
(match !jsxVersion with

# 946 "syntax/reactjs_jsx_ppx.cppo.ml"
# 947 "syntax/reactjs_jsx_ppx.cppo.ml"
| None
| Some 2 -> transformLowercaseCall mapper loc attrs callArguments id

# 952 "syntax/reactjs_jsx_ppx.cppo.ml"
# 953 "syntax/reactjs_jsx_ppx.cppo.ml"
| Some 3 -> transformLowercaseCall3 mapper loc attrs callArguments id
| Some _ -> raise (Invalid_argument "JSX: the JSX version must be 2 or 3"))

Expand Down Expand Up @@ -47553,17 +47554,17 @@ let jsxMapper () =
| ([], _) -> default_mapper.structure mapper structure
(* {jsx: 2} *)

# 1021 "syntax/reactjs_jsx_ppx.cppo.ml"
# 1022 "syntax/reactjs_jsx_ppx.cppo.ml"
| ((_, {pexp_desc = Pexp_constant (Pconst_integer (version, None))})::rest, recordFieldsWithoutJsx) -> begin

# 1025 "syntax/reactjs_jsx_ppx.cppo.ml"
# 1026 "syntax/reactjs_jsx_ppx.cppo.ml"
(match version with

# 1027 "syntax/reactjs_jsx_ppx.cppo.ml"
# 1028 "syntax/reactjs_jsx_ppx.cppo.ml"
| "2" -> jsxVersion := Some 2
| "3" -> jsxVersion := Some 3

# 1033 "syntax/reactjs_jsx_ppx.cppo.ml"
# 1034 "syntax/reactjs_jsx_ppx.cppo.ml"
| _ -> raise (Invalid_argument "JSX: the file-level bs.config's jsx version must be 2 or 3"));
match recordFieldsWithoutJsx with
(* record empty now, remove the whole bs.config attribute *)
Expand Down Expand Up @@ -48248,10 +48249,11 @@ let jsxMapper () =
| _ -> types
in

let argToConcreteType types (name, _loc, type_) = match name with
| name when isLabelled name || isOptional name ->
let argToConcreteType types (name, loc, type_) = match name with
| name when isLabelled name ->
(getLabel name, [], type_) :: types
(* return value *)
| name when isOptional name ->
(getLabel name, [], Typ.constr ~loc {loc; txt=optionIdent} [type_]) :: types
| _ -> types
in

Expand All @@ -48274,10 +48276,10 @@ let jsxMapper () =
| Ptyp_arrow (name, type_, ({ptyp_desc = Ptyp_arrow _} as rest)) when isLabelled name || isOptional name ->
getPropTypes ((name, ptyp_loc, type_)::types) rest

# 669 "syntax/reactjs_jsx_ppx.cppo.ml"
# 670 "syntax/reactjs_jsx_ppx.cppo.ml"
| Ptyp_arrow (Nolabel, _type, rest) ->

# 673 "syntax/reactjs_jsx_ppx.cppo.ml"
# 674 "syntax/reactjs_jsx_ppx.cppo.ml"
getPropTypes types rest
| Ptyp_arrow (name, type_, returnValue) when isLabelled name || isOptional name ->
(returnValue, (name, returnValue.ptyp_loc, type_)::types)
Expand Down Expand Up @@ -48339,10 +48341,10 @@ let jsxMapper () =
((fun expressionDesc -> {expression with pexp_desc = Pexp_let (recursive, vbs, wrapExpression expressionDesc)}), realReturnExpression)
(* let make = React.forwardRef((~prop) => ...) *)

# 734 "syntax/reactjs_jsx_ppx.cppo.ml"
# 735 "syntax/reactjs_jsx_ppx.cppo.ml"
| { pexp_desc = Pexp_apply (wrapperExpression, [(Nolabel, innerFunctionExpression)]) } ->

# 738 "syntax/reactjs_jsx_ppx.cppo.ml"
# 739 "syntax/reactjs_jsx_ppx.cppo.ml"
let (wrapExpression, realReturnExpression) = spelunkForFunExpression innerFunctionExpression in
((fun expressionDesc -> {
expression with pexp_desc =
Expand Down Expand Up @@ -48485,10 +48487,10 @@ let jsxMapper () =
| Ptyp_arrow (name, type_, ({ptyp_desc = Ptyp_arrow _} as rest)) when isOptional name || isLabelled name ->
getPropTypes ((name, ptyp_loc, type_)::types) rest

# 880 "syntax/reactjs_jsx_ppx.cppo.ml"
# 881 "syntax/reactjs_jsx_ppx.cppo.ml"
| Ptyp_arrow (Nolabel, _type, rest) ->

# 884 "syntax/reactjs_jsx_ppx.cppo.ml"
# 885 "syntax/reactjs_jsx_ppx.cppo.ml"
getPropTypes types rest
| Ptyp_arrow (name, type_, returnValue) when isOptional name || isLabelled name ->
(returnValue, (name, returnValue.ptyp_loc, type_)::types)
Expand Down Expand Up @@ -48536,11 +48538,11 @@ let jsxMapper () =
| {loc; txt = Ldot (modulePath, ("createElement" | "make"))} ->
(match !jsxVersion with

# 934 "syntax/reactjs_jsx_ppx.cppo.ml"
# 935 "syntax/reactjs_jsx_ppx.cppo.ml"
| Some 2 -> transformUppercaseCall modulePath mapper loc attrs callExpression callArguments
| None

# 937 "syntax/reactjs_jsx_ppx.cppo.ml"
# 938 "syntax/reactjs_jsx_ppx.cppo.ml"
| Some 3 -> transformUppercaseCall3 modulePath mapper loc attrs callExpression callArguments
| Some _ -> raise (Invalid_argument "JSX: the JSX version must be 2 or 3"))

Expand All @@ -48550,11 +48552,11 @@ let jsxMapper () =
| {loc; txt = Lident id} ->
(match !jsxVersion with

# 949 "syntax/reactjs_jsx_ppx.cppo.ml"
# 950 "syntax/reactjs_jsx_ppx.cppo.ml"
| Some 2 -> transformLowercaseCall mapper loc attrs callArguments id
| None

# 952 "syntax/reactjs_jsx_ppx.cppo.ml"
# 953 "syntax/reactjs_jsx_ppx.cppo.ml"
| Some 3 -> transformLowercaseCall3 mapper loc attrs callArguments id
| Some _ -> raise (Invalid_argument "JSX: the JSX version must be 2 or 3"))

Expand Down Expand Up @@ -48624,17 +48626,17 @@ let jsxMapper () =
| ([], _) -> default_mapper.structure mapper structure
(* {jsx: 2} *)

# 1021 "syntax/reactjs_jsx_ppx.cppo.ml"
# 1022 "syntax/reactjs_jsx_ppx.cppo.ml"
| ((_, {pexp_desc = Pexp_constant (Pconst_integer (version, None))})::rest, recordFieldsWithoutJsx) -> begin

# 1025 "syntax/reactjs_jsx_ppx.cppo.ml"
# 1026 "syntax/reactjs_jsx_ppx.cppo.ml"
(match version with

# 1027 "syntax/reactjs_jsx_ppx.cppo.ml"
# 1028 "syntax/reactjs_jsx_ppx.cppo.ml"
| "2" -> jsxVersion := Some 2
| "3" -> jsxVersion := Some 3

# 1033 "syntax/reactjs_jsx_ppx.cppo.ml"
# 1034 "syntax/reactjs_jsx_ppx.cppo.ml"
| _ -> raise (Invalid_argument "JSX: the file-level bs.config's jsx version must be 2 or 3"));
match recordFieldsWithoutJsx with
(* record empty now, remove the whole bs.config attribute *)
Expand Down
Loading