Commit 764f7ea5 authored by tom's avatar tom

refactor type utils

parent b875a1e2
......@@ -42,7 +42,7 @@ import type { TTxsFilters } from 'types/api/txsFilters';
import type { TxStateChanges } from 'types/api/txStateChanges';
import type { VisualizedContract } from 'types/api/visualization';
import type { WithdrawalsResponse } from 'types/api/withdrawals';
import type ArrayElement from 'types/utils/ArrayElement';
import type { ArrayElement } from 'types/utils';
import appConfig from 'configs/app/config';
......
export type ArrayElement<ArrayType extends Array<unknown>> =
ArrayType extends Array<(infer ElementType)> ? ElementType : never;
export type ExcludeNull<T> = T extends null ? never : T;
export type KeysOfObjectOrNull<T> = keyof ExcludeNull<T>;
type ArrayElement<ArrayType extends Array<unknown>> =
ArrayType extends Array<(infer ElementType)> ? ElementType : never;
export default ArrayElement;
export type ExcludeNull<T> = T extends null ? never : T;
import type { ExcludeNull } from './ExcludeNull';
export type KeysOfObjectOrNull<T> = keyof ExcludeNull<T>;
......@@ -2,7 +2,7 @@ import { Box, chakra } from '@chakra-ui/react';
import React from 'react';
import type { SearchResult } from './types';
import type ArrayElement from 'types/utils/ArrayElement';
import type { ArrayElement } from 'types/utils';
import useThemeColors from './utils/useThemeColors';
......
import type { FileTree } from '../types';
import type ArrayElement from 'types/utils/ArrayElement';
import type { ArrayElement } from 'types/utils';
export default function sortFileTree(a: ArrayElement<FileTree>, b: ArrayElement<FileTree>) {
if ('children' in a && !('children' in b)) {
......
......@@ -3,7 +3,7 @@ import BigNumber from 'bignumber.js';
import React from 'react';
import type { TxStateChange, TxStateChangeTokenErc1155, TxStateChangeTokenErc1155Single, TxStateChangeTokenErc721 } from 'types/api/txStateChanges';
import type ArrayElement from 'types/utils/ArrayElement';
import type { ArrayElement } from 'types/utils';
import appConfig from 'configs/app/config';
import { ZERO_ADDRESS } from 'lib/consts';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment