diff --git a/packages/core/src/api/modules/fetch.ts b/packages/core/src/api/modules/fetch.ts index 60ebc4e..a8db199 100644 --- a/packages/core/src/api/modules/fetch.ts +++ b/packages/core/src/api/modules/fetch.ts @@ -11,7 +11,7 @@ import { GetAPIConfig } from '../config'; /** * Endpoint */ -let endPoint = '{prefix}.json?icons={icons}'; +const endPoint = '{prefix}.json?icons={icons}'; /** * Cache @@ -120,7 +120,7 @@ export const getAPIModule: GetIconifyAPIModule = ( const iconsList = icons.join(','); const cacheKey = provider + ':' + prefix; - let path = + const path = pathCache[cacheKey] + endPoint .replace('{provider}', provider) @@ -144,7 +144,9 @@ export const getAPIModule: GetIconifyAPIModule = ( // Store cache and complete status.done(data); }) - .catch((err) => {}); + .catch(() => { + // + }); }; // Return functions diff --git a/packages/core/src/icon/index.ts b/packages/core/src/icon/index.ts index 85590d8..81cb9d4 100644 --- a/packages/core/src/icon/index.ts +++ b/packages/core/src/icon/index.ts @@ -2,7 +2,7 @@ import { IconifyIcon } from '@iconify/types'; import { merge } from '../misc/merge'; export { IconifyIcon }; -export type FullIconifyIcon = Required; +export type FullIconifyIcon = Omit, 'hidden'>; /** * Default values for IconifyIcon properties @@ -22,5 +22,5 @@ export const iconDefaults: FullIconifyIcon = Object.freeze({ * Create new icon with all properties */ export function fullIcon(icon: IconifyIcon): FullIconifyIcon { - return merge(iconDefaults, icon) as FullIconifyIcon; + return merge(iconDefaults, icon as FullIconifyIcon) as FullIconifyIcon; } diff --git a/packages/types/.gitignore b/packages/types/.gitignore new file mode 100644 index 0000000..9daa824 --- /dev/null +++ b/packages/types/.gitignore @@ -0,0 +1,2 @@ +.DS_Store +node_modules diff --git a/packages/types/package-lock.json b/packages/types/package-lock.json new file mode 100644 index 0000000..2f8f431 --- /dev/null +++ b/packages/types/package-lock.json @@ -0,0 +1,14 @@ +{ + "name": "@iconify/types", + "version": "1.0.5", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "typescript": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.0.5.tgz", + "integrity": "sha512-ywmr/VrTVCmNTJ6iV2LwIrfG1P+lv6luD8sUJs+2eI9NLGigaN+nUQc13iHqisq7bra9lnmUSYqbJvegraBOPQ==", + "dev": true + } + } +} diff --git a/packages/types/package.json b/packages/types/package.json index 2defe32..f4c8cbf 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,7 +1,7 @@ { "name": "@iconify/types", "description": "Types for Iconify data", - "version": "1.0.4", + "version": "1.0.5", "author": "Vjacheslav Trushkin", "license": "(Apache-2.0 OR GPL-2.0)", "main": "./index.js", @@ -16,6 +16,8 @@ "url": "https://github.com/iconify/iconify.git", "directory": "packages/types" }, - "devDependencies": {}, + "devDependencies": { + "typescript": "^4.0.5" + }, "dependencies": {} } diff --git a/packages/types/types.ts b/packages/types/types.ts index ff9bf69..1b549ff 100644 --- a/packages/types/types.ts +++ b/packages/types/types.ts @@ -54,10 +54,7 @@ export interface IconifyTransformations { export interface IconifyOptional extends IconifyDimenisons, IconifyTransformations { - // True if icon is hidden. - // Used in icon sets to keep icons that no longer exist, but should still be accessible - // from API, preventing websites from breaking when icon is removed by developer. - hidden?: boolean; + // } /** @@ -83,20 +80,33 @@ export interface IconifyIcon extends IconifyOptional { // If property is missing in JSON file, look in root object for default value. } +/** + * Icon with optional parameters that are provided by API and affect only search + */ +interface APIIconAttributes { + // True if icon is hidden. + // Used in icon sets to keep icons that no longer exist, but should still be accessible + // from API, preventing websites from breaking when icon is removed by developer. + hidden?: boolean; +} + +export interface ExtendedIconifyIcon extends IconifyIcon, APIIconAttributes {} +export interface ExtendedIconifyAlias extends IconifyAlias, APIIconAttributes {} + /** * "icons" field of JSON file. */ export interface IconifyIcons { - // Index is name of icon, without prefix. Value is IconifyIcon object. - [index: string]: IconifyIcon; + // Index is name of icon, without prefix. Value is ExtendedIconifyIcon object. + [index: string]: ExtendedIconifyIcon; } /** * "aliases" field of JSON file. */ export interface IconifyAliases { - // Index is name of icon, without prefix. Value is IconifyAlias object. - [index: string]: IconifyAlias; + // Index is name of icon, without prefix. Value is ExtendedIconifyAlias object. + [index: string]: ExtendedIconifyAlias; } /**