mirror of
https://github.com/iconify/iconify.git
synced 2024-11-09 23:00:56 +00:00
refactor(types): refactored away ts errors
This commit is contained in:
parent
fa01bbe962
commit
30ab5eba2a
@ -19,7 +19,7 @@ export function getIcons(
|
||||
): IconifyJSON | null {
|
||||
const result: IconifyJSON = {
|
||||
prefix: data.prefix,
|
||||
icons: Object.create(null),
|
||||
icons: Object.create(null) as never,
|
||||
};
|
||||
const tested: Set<string> = new Set();
|
||||
let empty = true;
|
||||
@ -43,9 +43,9 @@ export function getIcons(
|
||||
const copied = copy(data.aliases[name].parent, iteration + 1);
|
||||
if (copied) {
|
||||
if (result.aliases === void 0) {
|
||||
result.aliases = Object.create(null);
|
||||
result.aliases = Object.create(null) as never;
|
||||
}
|
||||
result.aliases![name] = { ...data.aliases[name] };
|
||||
result.aliases[name] = { ...data.aliases[name] };
|
||||
}
|
||||
return copied;
|
||||
}
|
||||
@ -56,9 +56,9 @@ export function getIcons(
|
||||
const copied = copy(parent, iteration + 1);
|
||||
if (copied) {
|
||||
if (result.aliases === void 0) {
|
||||
result.aliases = Object.create(null);
|
||||
result.aliases = Object.create(null) as never;
|
||||
}
|
||||
result.aliases![name] = {
|
||||
result.aliases[name] = {
|
||||
parent,
|
||||
};
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ export async function loadCollectionFromFS(
|
||||
name: string,
|
||||
autoInstall = false
|
||||
): Promise<IconifyJSON | undefined> {
|
||||
if (!_collections[name]) {
|
||||
if (!(await _collections[name])) {
|
||||
_collections[name] = task();
|
||||
}
|
||||
return _collections[name];
|
||||
|
@ -32,7 +32,10 @@ async function importFsModule(): Promise<typeof import('./fs') | undefined> {
|
||||
} catch {
|
||||
try {
|
||||
// cjs environments
|
||||
return require('./fs.js');
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
return require('./fs.js') as Promise<
|
||||
typeof import('./fs') | undefined
|
||||
>;
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
@ -45,9 +48,18 @@ async function loadNodeBuiltinIcon(
|
||||
options?: IconifyLoaderOptions,
|
||||
warn = true
|
||||
): Promise<string | undefined> {
|
||||
type IconifyJSON = Parameters<typeof searchForIcon>[0];
|
||||
type LoadCollectionFromFS = (
|
||||
collection: string,
|
||||
autoInstall?: boolean
|
||||
) => Promise<IconifyJSON>;
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
const { loadCollectionFromFS } = await importFsModule();
|
||||
const {
|
||||
loadCollectionFromFS,
|
||||
}: {
|
||||
loadCollectionFromFS: LoadCollectionFromFS;
|
||||
} = await importFsModule();
|
||||
const iconSet = await loadCollectionFromFS(
|
||||
collection,
|
||||
options?.autoInstall
|
||||
|
@ -2,7 +2,14 @@ import { validateIconSet } from '../lib/icon-set/validate';
|
||||
|
||||
describe('Testing validating icon', () => {
|
||||
// Add various types for testing
|
||||
const validationValues = new Map();
|
||||
const validationValues = new Map<
|
||||
| boolean
|
||||
| Record<string | number | symbol, never>
|
||||
| []
|
||||
| number
|
||||
| string,
|
||||
{ text: string; type: string }
|
||||
>();
|
||||
|
||||
beforeAll(() => {
|
||||
validationValues.set(true, {
|
||||
|
Loading…
Reference in New Issue
Block a user