add types for font-awesome-v5-icons
Possibly temporary, see soul-wish/font-awesome-v5-icons#25deepsource-autofix-76c6eb20
parent
bd3c183cc5
commit
3af9e39254
|
|
@ -2,7 +2,7 @@ import faIcons from "font-awesome-v5-icons";
|
|||
let solidIcons = [];
|
||||
export const getSolidIconClasses = async () => {
|
||||
if (solidIcons.length === 0) {
|
||||
const allIcons = await faIcons.getList();
|
||||
const allIcons = await faIcons.getListByKeys(["name", "styles"]);
|
||||
const list = [];
|
||||
for (const icon of allIcons) {
|
||||
if (icon.styles.includes("solid")) {
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@ let solidIcons: string[] = [];
|
|||
|
||||
export const getSolidIconClasses = async () => {
|
||||
if (solidIcons.length === 0) {
|
||||
const allIcons = await faIcons.getList();
|
||||
const allIcons = await faIcons.getListByKeys(["name", "styles"]);
|
||||
|
||||
const list: string[] = [];
|
||||
|
||||
for (const icon of allIcons) {
|
||||
if ((icon.styles as string[]).includes("solid")) {
|
||||
if (icon.styles.includes("solid")) {
|
||||
list.push(icon.name);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
declare module "font-awesome-v5-icons" {
|
||||
type FontAwesomeV5Styles = "solid" | "regular" | "brands";
|
||||
type FontAwesomeV5Keys = "name" | "changes" | "label" | "search" | "styles" | "unicode" | "voted";
|
||||
interface FontAwesomeV5Icon {
|
||||
name?: string;
|
||||
changes?: string[];
|
||||
label?: string;
|
||||
search?: {
|
||||
terms: string[];
|
||||
};
|
||||
styles?: FontAwesomeV5Styles[];
|
||||
unicode?: string;
|
||||
voted?: boolean;
|
||||
}
|
||||
function getList(): Promise<FontAwesomeV5Icon[]>;
|
||||
function getListByKeys(arrayOfNeededKeys: FontAwesomeV5Keys[]): Promise<FontAwesomeV5Icon[]>;
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
declare module "font-awesome-v5-icons" {
|
||||
type FontAwesomeV5Styles = "solid" | "regular" | "brands";
|
||||
|
||||
type FontAwesomeV5Keys =
|
||||
| "name"
|
||||
| "changes"
|
||||
| "label"
|
||||
| "search"
|
||||
| "styles"
|
||||
| "unicode"
|
||||
| "voted";
|
||||
|
||||
interface FontAwesomeV5Icon {
|
||||
name?: string;
|
||||
changes?: string[];
|
||||
label?: string;
|
||||
search?: { terms: string[] };
|
||||
styles?: FontAwesomeV5Styles[];
|
||||
unicode?: string;
|
||||
voted?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a promise with a full list of actual Font Awesome v5 icons.
|
||||
*/
|
||||
export function getList(): Promise<FontAwesomeV5Icon[]>;
|
||||
|
||||
/**
|
||||
* Returns a promise with a full list of Font Awesome icons with needed keys only.
|
||||
* @param arrayOfNeededKeys
|
||||
*/
|
||||
export function getListByKeys(
|
||||
arrayOfNeededKeys: FontAwesomeV5Keys[]
|
||||
): Promise<FontAwesomeV5Icon[]>;
|
||||
}
|
||||
Loading…
Reference in New Issue