From 8088446401a5f830f83dfb0ee1675f08fdd60b4b Mon Sep 17 00:00:00 2001 From: Fedor Nezhivoi Date: Sun, 16 Jul 2017 22:43:46 +0300 Subject: [PATCH] @types/react-native: fix style related bugs --- types/react-native/index.d.ts | 13 +++++++------ types/react-native/test/index.tsx | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index f3f90b88f9..3317eff673 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -1657,7 +1657,9 @@ export interface ViewPropertiesAndroid { } -export type StyleProp = T | Array +type Falsy = undefined | null | false +interface RecursiveArray extends Array> {} +export type StyleProp = T | RecursiveArray | Falsy /** * @see https://facebook.github.io/react-native/docs/view.html#props @@ -4904,11 +4906,8 @@ export namespace NavigatorStatic { // @see https://github.com/facebook/react-native/blob/0.34-stable\Libraries\StyleSheet\StyleSheetTypes.js export namespace StyleSheet { - - type Style = ViewStyle | TextStyle | ImageStyle - type NamedStyles = { - [P in keyof T]: Style; + [P in keyof T]: ViewStyle | TextStyle | ImageStyle; } /** @@ -4955,7 +4954,9 @@ export namespace StyleSheet { * their respective objects, merged as one and then returned. This also explains * the alternative use. */ - export function flatten(style?: Style | Style[]): Style + export function flatten(style?: StyleProp): ViewStyle + export function flatten(style?: StyleProp): TextStyle + export function flatten(style?: StyleProp): ImageStyle /** * This is defined as the width of a thin line on the platform. It can be diff --git a/types/react-native/test/index.tsx b/types/react-native/test/index.tsx index 269162c9f3..446cb176f1 100644 --- a/types/react-native/test/index.tsx +++ b/types/react-native/test/index.tsx @@ -141,7 +141,7 @@ class Welcome extends React.Component { render() { return ( - + Welcome to React Native