mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-11 03:27:47 +08:00
react-native-vector-icons: allow omitting variant
This commit is contained in:
@@ -16,14 +16,14 @@ type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
|
||||
|
||||
export type FontAwesome5IconVariants = keyof Omit<typeof FA5Style, "regular">;
|
||||
|
||||
// borrowed from https://stackoverflow.com/a/49725198/1105281
|
||||
type RequireOnlyOne<T, Keys extends keyof T = keyof T> = Omit<T, Keys> &
|
||||
// modified from https://stackoverflow.com/a/49725198/1105281
|
||||
type AllowOnlyOne<T, Keys extends keyof T = keyof T> = Omit<T, Keys> &
|
||||
{
|
||||
[K in Keys]-?: Required<Pick<T, K>> &
|
||||
[K in Keys]-?: Partial<Pick<T, K>> &
|
||||
Partial<Record<Exclude<Keys, K>, undefined>>
|
||||
}[Keys];
|
||||
|
||||
export type FontAwesome5IconProps = RequireOnlyOne<
|
||||
export type FontAwesome5IconProps = AllowOnlyOne<
|
||||
{ [K in FontAwesome5IconVariants]?: boolean } & IconProps,
|
||||
FontAwesome5IconVariants
|
||||
>;
|
||||
|
||||
@@ -29,6 +29,7 @@ class Example extends React.Component {
|
||||
<View>
|
||||
{/* Normal Icon */}
|
||||
<MaterialIcon size={30} color="red" name="exit" />
|
||||
<FontAwesome5Icon size={10} name="handshake" />
|
||||
<FontAwesome5Icon size={10} name="handshake" solid />
|
||||
<FontAwesome5ProIcon size={10} name="parachute-box" light />
|
||||
|
||||
|
||||
Reference in New Issue
Block a user