From 9761062ec241828c149f730fc840d91ae5aaebbc Mon Sep 17 00:00:00 2001 From: Benas Svipas Date: Mon, 1 Jul 2019 12:53:00 +0300 Subject: [PATCH] @types/react-native: fix StyleSheet.create() styles parameter (#36554) * Fix StyleSheet.create() styles parameter * Add tests --- types/react-native/index.d.ts | 2 +- types/react-native/test/stylesheet-create.tsx | 15 +++++++++++++++ types/react-native/tsconfig.json | 3 ++- 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 types/react-native/test/stylesheet-create.tsx diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index 126e340836..ce2945cfd0 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -5320,7 +5320,7 @@ export namespace StyleSheet { /** * Creates a StyleSheet style reference from the given object. */ - export function create | NamedStyles>(styles: T): T; + export function create | NamedStyles>(styles: T | NamedStyles): T; /** * Flattens an array of style objects, into one aggregated style object. diff --git a/types/react-native/test/stylesheet-create.tsx b/types/react-native/test/stylesheet-create.tsx new file mode 100644 index 0000000000..0b887cc75e --- /dev/null +++ b/types/react-native/test/stylesheet-create.tsx @@ -0,0 +1,15 @@ +import * as React from 'react'; +import { View, StyleSheet } from 'react-native'; + +export function App() { + return ; +} + +const styles = StyleSheet.create({ + container: { + position: 'absolute', + backgroundColor: 'red', + width: '100%', + height: '100%', + }, +}); diff --git a/types/react-native/tsconfig.json b/types/react-native/tsconfig.json index d982fe1be7..59c066952c 100644 --- a/types/react-native/tsconfig.json +++ b/types/react-native/tsconfig.json @@ -22,6 +22,7 @@ "test/animated.tsx", "test/init-example.tsx", "test/ART.tsx", - "test/legacy-properties.tsx" + "test/legacy-properties.tsx", + "test/stylesheet-create.tsx" ] }