Files
react-native/packages
D N 1ea269f42c fix: [TypeScript] Allow to pass empty string as style (#43404)
Summary:
```tsx
import {Text} from 'react-native'

interface Props {
  foregroundColor?: string | undefined | null
}

function Test({foregroundColor}: Props){
  return <Text style=[styles.icon, foregroundColor && { color: foregroundColor }] />
  // ^^^ Error: Type "" is not assignable to type TextStyle | Falsy | RegisteredStyle<TextStyle> | RecursiveArray<TextStyle...
}
```

## Changelog:

[GENERAL] [ADDED] - [TypeScript] Allow to pass empty string as style

Pull Request resolved: https://github.com/facebook/react-native/pull/43404

Test Plan:
Change `Falsy` type locally and test it on the next code

```tsx
const styles = StyleSheet.create({
  text: {
    color: 'red',
  },
});
export const a = <Text style={[styles.text, null, '', undefined, false]} />;
```

Reviewed By: rshest

Differential Revision: D54744517

Pulled By: javache

fbshipit-source-id: c5b934616cc0501c2b6a7907e6be522187a2cc20
2024-03-11 06:00:36 -07:00
..