mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2025-07-22 06:00:07 +03:00
Tighten types
This commit is contained in:
parent
1de4f48200
commit
9466c868be
|
@ -3,7 +3,7 @@ import JSONArrow from './JSONArrow';
|
||||||
import type { CircularCache, CommonInternalProps } from './types';
|
import type { CircularCache, CommonInternalProps } from './types';
|
||||||
|
|
||||||
interface Props extends CommonInternalProps {
|
interface Props extends CommonInternalProps {
|
||||||
data: any;
|
data: unknown;
|
||||||
nodeType: string;
|
nodeType: string;
|
||||||
from: number;
|
from: number;
|
||||||
to: number;
|
to: number;
|
||||||
|
|
|
@ -4,14 +4,14 @@ import type { CommonInternalProps } from './types';
|
||||||
|
|
||||||
// Returns the "n Items" string for this node,
|
// Returns the "n Items" string for this node,
|
||||||
// generating and caching it if it hasn't been created yet.
|
// generating and caching it if it hasn't been created yet.
|
||||||
function createItemString(data: any) {
|
function createItemString(data: unknown) {
|
||||||
return `${(data as unknown[]).length} ${
|
return `${(data as unknown[]).length} ${
|
||||||
(data as unknown[]).length !== 1 ? 'items' : 'item'
|
(data as unknown[]).length !== 1 ? 'items' : 'item'
|
||||||
}`;
|
}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Props extends CommonInternalProps {
|
interface Props extends CommonInternalProps {
|
||||||
data: any;
|
data: unknown;
|
||||||
nodeType: string;
|
nodeType: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ export default function JSONArrayNode({ data, ...props }: Props) {
|
||||||
nodeType="Array"
|
nodeType="Array"
|
||||||
nodeTypeIndicator="[]"
|
nodeTypeIndicator="[]"
|
||||||
createItemString={createItemString}
|
createItemString={createItemString}
|
||||||
expandable={data.length > 0}
|
expandable={(data as unknown[]).length > 0}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ function createItemString(data: any, limit: number) {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Props extends CommonInternalProps {
|
interface Props extends CommonInternalProps {
|
||||||
data: any;
|
data: unknown;
|
||||||
nodeType: string;
|
nodeType: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ import type { CircularCache, CommonInternalProps } from './types';
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export interface RenderChildNodesProps extends CommonInternalProps {
|
export interface RenderChildNodesProps extends CommonInternalProps {
|
||||||
data: any;
|
data: unknown;
|
||||||
nodeType: string;
|
nodeType: string;
|
||||||
circularCache: CircularCache;
|
circularCache: CircularCache;
|
||||||
level: number;
|
level: number;
|
||||||
|
@ -23,7 +23,7 @@ interface Range {
|
||||||
|
|
||||||
interface Entry {
|
interface Entry {
|
||||||
key: string | number;
|
key: string | number;
|
||||||
value: any;
|
value: unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isRange(rangeOrEntry: Range | Entry): rangeOrEntry is Range {
|
function isRange(rangeOrEntry: Range | Entry): rangeOrEntry is Range {
|
||||||
|
@ -87,10 +87,10 @@ function renderChildNodes(
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Props extends CommonInternalProps {
|
interface Props extends CommonInternalProps {
|
||||||
data: any;
|
data: unknown;
|
||||||
nodeType: string;
|
nodeType: string;
|
||||||
nodeTypeIndicator: string;
|
nodeTypeIndicator: string;
|
||||||
createItemString: (data: any, collectionLimit: number) => string;
|
createItemString: (data: unknown, collectionLimit: number) => string;
|
||||||
expandable: boolean;
|
expandable: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import JSONValueNode from './JSONValueNode';
|
||||||
import type { CommonInternalProps } from './types';
|
import type { CommonInternalProps } from './types';
|
||||||
|
|
||||||
interface Props extends CommonInternalProps {
|
interface Props extends CommonInternalProps {
|
||||||
value: any;
|
value: unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function JSONNode({
|
export default function JSONNode({
|
||||||
|
|
|
@ -4,13 +4,13 @@ import type { CommonInternalProps } from './types';
|
||||||
|
|
||||||
// Returns the "n Items" string for this node,
|
// Returns the "n Items" string for this node,
|
||||||
// generating and caching it if it hasn't been created yet.
|
// generating and caching it if it hasn't been created yet.
|
||||||
function createItemString(data: any) {
|
function createItemString(data: unknown) {
|
||||||
const len = Object.getOwnPropertyNames(data).length;
|
const len = Object.getOwnPropertyNames(data).length;
|
||||||
return `${len} ${len !== 1 ? 'keys' : 'key'}`;
|
return `${len} ${len !== 1 ? 'keys' : 'key'}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Props extends CommonInternalProps {
|
interface Props extends CommonInternalProps {
|
||||||
data: any;
|
data: unknown;
|
||||||
nodeType: string;
|
nodeType: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,9 +19,9 @@ interface Props {
|
||||||
labelRenderer: LabelRenderer;
|
labelRenderer: LabelRenderer;
|
||||||
nodeType: string;
|
nodeType: string;
|
||||||
styling: Styling;
|
styling: Styling;
|
||||||
value: any;
|
value: unknown;
|
||||||
valueRenderer: ValueRenderer;
|
valueRenderer: ValueRenderer;
|
||||||
valueGetter?: (value: any) => any;
|
valueGetter?: (value: any) => unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function JSONValueNode({
|
export default function JSONValueNode({
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import type { SortObjectKeys } from './types';
|
import type { SortObjectKeys } from './types';
|
||||||
|
|
||||||
function getLength(type: string, collection: any) {
|
function getLength(type: string, collection: unknown) {
|
||||||
if (type === 'Object') {
|
if (type === 'Object') {
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||||
return Object.keys(collection as {}).length;
|
return Object.keys(collection as {}).length;
|
||||||
|
@ -11,8 +11,8 @@ function getLength(type: string, collection: any) {
|
||||||
return Infinity;
|
return Infinity;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isIterableMap(collection: any) {
|
function isIterableMap(collection: unknown) {
|
||||||
return typeof (collection as Map<any, any>).set === 'function';
|
return typeof (collection as Map<unknown, unknown>).set === 'function';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getEntries(
|
function getEntries(
|
||||||
|
@ -21,7 +21,7 @@ function getEntries(
|
||||||
sortObjectKeys: SortObjectKeys,
|
sortObjectKeys: SortObjectKeys,
|
||||||
from = 0,
|
from = 0,
|
||||||
to = Infinity
|
to = Infinity
|
||||||
): { entries: { key: string | number; value: any }[]; hasMore?: boolean } {
|
): { entries: { key: string | number; value: unknown }[]; hasMore?: boolean } {
|
||||||
let res;
|
let res;
|
||||||
|
|
||||||
if (type === 'Object') {
|
if (type === 'Object') {
|
||||||
|
@ -97,7 +97,7 @@ function getRanges(from: number, to: number, limit: number) {
|
||||||
|
|
||||||
export default function getCollectionEntries(
|
export default function getCollectionEntries(
|
||||||
type: string,
|
type: string,
|
||||||
collection: any,
|
collection: unknown,
|
||||||
sortObjectKeys: SortObjectKeys,
|
sortObjectKeys: SortObjectKeys,
|
||||||
limit: number,
|
limit: number,
|
||||||
from = 0,
|
from = 0,
|
||||||
|
|
|
@ -17,7 +17,7 @@ import type {
|
||||||
} from './types';
|
} from './types';
|
||||||
|
|
||||||
interface Props extends Partial<CommonExternalProps> {
|
interface Props extends Partial<CommonExternalProps> {
|
||||||
data: any;
|
data: unknown;
|
||||||
theme?: Theme;
|
theme?: Theme;
|
||||||
invertTheme?: boolean;
|
invertTheme?: boolean;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,11 @@ import { StylingFunction } from 'react-base16-styling';
|
||||||
|
|
||||||
export type Key = string | number;
|
export type Key = string | number;
|
||||||
|
|
||||||
export type KeyPath = (string | number)[];
|
export type KeyPath = readonly (string | number)[];
|
||||||
|
|
||||||
export type GetItemString = (
|
export type GetItemString = (
|
||||||
nodeType: string,
|
nodeType: string,
|
||||||
data: any,
|
data: unknown,
|
||||||
itemType: React.ReactNode,
|
itemType: React.ReactNode,
|
||||||
itemString: string,
|
itemString: string,
|
||||||
keyPath: KeyPath
|
keyPath: KeyPath
|
||||||
|
@ -21,26 +21,26 @@ export type LabelRenderer = (
|
||||||
) => React.ReactNode;
|
) => React.ReactNode;
|
||||||
|
|
||||||
export type ValueRenderer = (
|
export type ValueRenderer = (
|
||||||
valueAsString: any,
|
valueAsString: unknown,
|
||||||
value: any,
|
value: unknown,
|
||||||
...keyPath: KeyPath
|
...keyPath: KeyPath
|
||||||
) => React.ReactNode;
|
) => React.ReactNode;
|
||||||
|
|
||||||
export type ShouldExpandNodeInitially = (
|
export type ShouldExpandNodeInitially = (
|
||||||
keyPath: KeyPath,
|
keyPath: KeyPath,
|
||||||
data: any,
|
data: unknown,
|
||||||
level: number
|
level: number
|
||||||
) => boolean;
|
) => boolean;
|
||||||
|
|
||||||
export type PostprocessValue = (value: any) => any;
|
export type PostprocessValue = (value: unknown) => unknown;
|
||||||
|
|
||||||
export type IsCustomNode = (value: any) => boolean;
|
export type IsCustomNode = (value: unknown) => boolean;
|
||||||
|
|
||||||
export type SortObjectKeys = ((a: any, b: any) => number) | boolean;
|
export type SortObjectKeys = ((a: unknown, b: unknown) => number) | boolean;
|
||||||
|
|
||||||
export type Styling = StylingFunction;
|
export type Styling = StylingFunction;
|
||||||
|
|
||||||
export type CircularCache = any[];
|
export type CircularCache = unknown[];
|
||||||
|
|
||||||
export interface CommonExternalProps {
|
export interface CommonExternalProps {
|
||||||
keyPath: KeyPath;
|
keyPath: KeyPath;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user