This repository was archived by the owner on Jun 15, 2023. It is now read-only.
File tree 3 files changed +26
-13
lines changed
3 files changed +26
-13
lines changed Original file line number Diff line number Diff line change @@ -183,7 +183,16 @@ let recordFromProps ~loc ~removeKey callArguments =
183
183
| (Nolabel, {pexp_loc} ) :: _rest ->
184
184
React_jsx_common. raiseError ~loc: pexp_loc
185
185
" JSX: found non-labelled argument before the last position"
186
- | prop :: rest -> removeLastPositionUnitAux rest (prop :: acc)
186
+ | ((Labelled txt, {pexp_loc}) as prop) :: rest
187
+ | ((Optional txt , {pexp_loc} ) as prop ) :: rest ->
188
+ if txt = " _spreadProps" then
189
+ match acc with
190
+ | [] -> removeLastPositionUnitAux rest (prop :: acc)
191
+ | _ ->
192
+ React_jsx_common. raiseError ~loc: pexp_loc
193
+ " JSX: spread props should be first in order than other props\n \
194
+ \ and multiple spread props are not allowed."
195
+ else removeLastPositionUnitAux rest (prop :: acc)
187
196
in
188
197
let props, propsToSpread =
189
198
removeLastPositionUnitAux callArguments []
Original file line number Diff line number Diff line change 1
1
@@jsxConfig({version: 4, mode: "classic"})
2
- let c0 = React.createElement(A.make, {...p, x: "x"})
2
+ // Error: spreadProps should be first in order than other props
3
+ // let c0 = <A x="x" {...p} />
3
4
4
- // ignore second one
5
- let c0 = React.createElement(A.make, {...p0, x: "x"})
5
+ // Error: multiple spreadProps not allowed
6
+ // let c0 = <A x="x" {...p0} {...p1} />
6
7
7
8
// only spread props
8
9
let c1 = React.createElement(A.make, p)
@@ -11,10 +12,11 @@ let c1 = React.createElement(A.make, p)
11
12
let c2 = React.createElement(A.make, {...p, x: "x"})
12
13
13
14
@@jsxConfig({version: 4, mode: "automatic"})
14
- let c0 = React.jsx(A.make, {...p, x: "x"})
15
+ // Error: spreadProps should be first in order than other props
16
+ // let c0 = <A x="x" {...p} />
15
17
16
- // ignore second one
17
- let c0 = React.jsx(A.make, {...p0, x: "x"})
18
+ // Error: multiple spreadProps not allowed
19
+ // let c0 = <A x="x" {...p0} {...p1} />
18
20
19
21
// only spread props
20
22
let c1 = React.jsx(A.make, p)
Original file line number Diff line number Diff line change 1
1
@@jsxConfig ({version :4 , mode : "classic" })
2
- let c0 = <A x = "x" {... p } />
2
+ // Error: spreadProps should be first in order than other props
3
+ // let c0 = <A x="x" {...p} />
3
4
4
- // ignore second one
5
- let c0 = <A x = "x" {... p0 } {... p1 } />
5
+ // Error: multiple spreadProps not allowed
6
+ // let c0 = <A x="x" {...p0} {...p1} />
6
7
7
8
// only spread props
8
9
let c1 = <A {... p } />
@@ -11,10 +12,11 @@ let c1 = <A {...p} />
11
12
let c2 = <A {... p } x = "x" />
12
13
13
14
@@jsxConfig ({version :4 , mode : "automatic" })
14
- let c0 = <A x = "x" {... p } />
15
+ // Error: spreadProps should be first in order than other props
16
+ // let c0 = <A x="x" {...p} />
15
17
16
- // ignore second one
17
- let c0 = <A x = "x" {... p0 } {... p1 } />
18
+ // Error: multiple spreadProps not allowed
19
+ // let c0 = <A x="x" {...p0} {...p1} />
18
20
19
21
// only spread props
20
22
let c1 = <A {... p } />
You can’t perform that action at this time.
0 commit comments