77 *
88 */
99
10- /* eslint-disable no-unused-vars */
10+ /* eslint-disable no-unused-vars, react/no-unknown-property */
1111
1212import * as React from 'react' ;
1313import * as stylex from '@stylexjs/stylex' ;
14- import type { StaticStyles } from '@stylexjs/stylex' ;
14+ import type { StaticStyles , StyleXSxProp } from '@stylexjs/stylex' ;
1515
1616type Props = {
1717 xstyle ?: StaticStyles ;
@@ -21,16 +21,40 @@ function Component({ xstyle }: Props) {
2121 return < div { ...stylex . props ( xstyle ) } /> ;
2222}
2323
24+ function PlainComponent ( _props : { } ) {
25+ return null ;
26+ }
27+
2428const styles = stylex . create ( {
2529 base : {
2630 color : 'red' ,
2731 } ,
2832} ) ;
2933
34+ const sxStyle : StyleXSxProp = styles . base ;
35+
3036function OtherComponent ( ) {
3137 return < Component xstyle = { styles . base } /> ;
3238}
3339
3440function OtherComponent2 ( ) {
3541 return < Component xstyle = { [ styles . base , undefined ] } /> ;
3642}
43+
44+ function SxComponent ( ) {
45+ return < div sx = { styles . base } /> ;
46+ }
47+
48+ function SxComponentMultiStyle ( ) {
49+ return < div sx = { [ styles . base , undefined ] } /> ;
50+ }
51+
52+ function InvalidSxValue ( ) {
53+ // @ts -expect-error - `sx` only accepts StyleX styles.
54+ return < div sx = "not-stylex" /> ;
55+ }
56+
57+ function CustomComponentSx ( ) {
58+ // @ts -expect-error - `sx` is only transformed on lowercase JSX host elements.
59+ return < PlainComponent sx = { styles . base } /> ;
60+ }
0 commit comments