diff --git a/types/react-native-vector-icons/FontAwesome5.d.ts b/types/react-native-vector-icons/FontAwesome5.d.ts new file mode 100644 index 0000000000..7d40fe2c5d --- /dev/null +++ b/types/react-native-vector-icons/FontAwesome5.d.ts @@ -0,0 +1,43 @@ +import { Component } from "../../../../../Library/Caches/typescript/2.9/node_modules/@types/react"; +import { Icon, IconProps, ImageSource } from "./Icon"; + +export const FA5Style: { + regular: 0; + light: 1; + solid: 2; + brand: 3; +}; + +type ValueOf = T[keyof T]; + +// borrowed from +// https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html +type Omit = Pick>; + +export type FontAwesome5IconVariants = keyof Omit; + +// borrowed from https://stackoverflow.com/a/49725198/1105281 +type RequireOnlyOne = Omit & + { + [K in Keys]-?: Required> & + Partial, undefined>> + }[Keys]; + +export type FontAwesome5IconProps = RequireOnlyOne< + { [K in FontAwesome5IconVariants]?: boolean } & IconProps, + FontAwesome5IconVariants +>; + +export default class FontAwesome5Icon extends Component< + FontAwesome5IconProps, + any +> { + static getImageSource( + name: string, + size?: number, + color?: string, + fa5Style?: ValueOf + ): Promise; + static loadFont(file?: string): Promise; + static hasIcon(name: string): boolean; +} diff --git a/types/react-native-vector-icons/FontAwesome5Pro.d.ts b/types/react-native-vector-icons/FontAwesome5Pro.d.ts new file mode 100644 index 0000000000..f8233abce5 --- /dev/null +++ b/types/react-native-vector-icons/FontAwesome5Pro.d.ts @@ -0,0 +1,6 @@ +import { Component } from "react"; +import FontAwesome5Icon, { FontAwesome5IconProps } from "./FontAwesome5"; + +export type FontAwesome5ProIconProps = FontAwesome5IconProps; +export { FA5Style } from "./FontAwesome5"; +export default FontAwesome5Icon;