2
0
mirror of https://github.com/iconify/iconify.git synced 2024-12-12 13:47:49 +00:00

Add TypeScript as dev dependency to types, move hidden field from icon object, so it affects only JSON structure

This commit is contained in:
Vjacheslav Trushkin 2020-11-05 11:35:41 +02:00
parent 5f9a03899c
commit 4ac1f0f199
6 changed files with 45 additions and 15 deletions

View File

@ -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

View File

@ -2,7 +2,7 @@ import { IconifyIcon } from '@iconify/types';
import { merge } from '../misc/merge';
export { IconifyIcon };
export type FullIconifyIcon = Required<IconifyIcon>;
export type FullIconifyIcon = Omit<Required<IconifyIcon>, '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;
}

2
packages/types/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.DS_Store
node_modules

14
packages/types/package-lock.json generated Normal file
View File

@ -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
}
}
}

View File

@ -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": {}
}

View File

@ -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;
}
/**