From a7340f9be34dccec4f619a98144413b2bb875bf6 Mon Sep 17 00:00:00 2001 From: Omar Diab Date: Wed, 15 Aug 2018 00:02:12 +0900 Subject: [PATCH] react-native-vector-icons: allow omitting variant --- types/react-native-vector-icons/FontAwesome5.d.ts | 8 ++++---- .../react-native-vector-icons-tests.tsx | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/types/react-native-vector-icons/FontAwesome5.d.ts b/types/react-native-vector-icons/FontAwesome5.d.ts index 7d40fe2c5d..18df444e79 100644 --- a/types/react-native-vector-icons/FontAwesome5.d.ts +++ b/types/react-native-vector-icons/FontAwesome5.d.ts @@ -16,14 +16,14 @@ type Omit = Pick>; export type FontAwesome5IconVariants = keyof Omit; -// borrowed from https://stackoverflow.com/a/49725198/1105281 -type RequireOnlyOne = Omit & +// modified from https://stackoverflow.com/a/49725198/1105281 +type AllowOnlyOne = Omit & { - [K in Keys]-?: Required> & + [K in Keys]-?: Partial> & Partial, undefined>> }[Keys]; -export type FontAwesome5IconProps = RequireOnlyOne< +export type FontAwesome5IconProps = AllowOnlyOne< { [K in FontAwesome5IconVariants]?: boolean } & IconProps, FontAwesome5IconVariants >; diff --git a/types/react-native-vector-icons/react-native-vector-icons-tests.tsx b/types/react-native-vector-icons/react-native-vector-icons-tests.tsx index e0dcaeb9b6..18b03edcaa 100644 --- a/types/react-native-vector-icons/react-native-vector-icons-tests.tsx +++ b/types/react-native-vector-icons/react-native-vector-icons-tests.tsx @@ -29,6 +29,7 @@ class Example extends React.Component { {/* Normal Icon */} +