facebook / stylex

StyleX is the styling system for ambitious user interfaces.
https://stylexjs.com
MIT License
8.34k stars 307 forks source link

Allow undefined where null is allowed #417

Closed steida closed 7 months ago

steida commented 7 months ago

Describe the feature request

Is there a reason why undefined isn't supported? My component has optional titleStyle, so it can be undefined.

Now I have to convert undefined to false titleStyle != null

<Text
  style={[
    styles.title,
    styles[variant],
    titleStyle != null && titleStyle,
    hovered && styles.titleHover,
    pressed && styles.titlePressed,
  ]}
>
  {title}
</Text>
nmn commented 7 months ago

undefined should be supported when used there. I'll look into it.

steida commented 7 months ago

@nmn Maybe it's because of exactOptionalPropertyTypes

https://github.com/Effect-TS/effect/tree/main/packages/schema#requirements

nmn commented 7 months ago

Thanks for catching this. Put up a PR with the fix.