style: types

This commit is contained in:
wuji.xwt 2020-09-10 17:40:32 +08:00
parent b4a6d69727
commit cdad47fc94
4 changed files with 14 additions and 14 deletions

View File

@ -1,10 +1,10 @@
import { EventEmitter } from 'events'; import { EventEmitter } from 'events';
import { ReactNode, ReactElement, RefObject, ComponentType } from 'react'; import { ReactNode, ComponentType } from 'react';
import { NpmInfo } from './npm'; import { NpmInfo } from './npm';
import { RegisterOptions } from 'power-di'; import { RegisterOptions } from 'power-di';
export type KeyType = Function | symbol | string; export type KeyType = new (...args: any[]) => any | symbol | string;
export type ClassType = Function | (new (...args: any[]) => any); export type ClassType = new (...args: any[]) => any;
export interface GetOptions { export interface GetOptions {
forceNew?: boolean; forceNew?: boolean;
sourceCls?: ClassType; sourceCls?: ClassType;
@ -48,7 +48,7 @@ export interface EditorConfig {
export interface SkeletonConfig { export interface SkeletonConfig {
config: NpmInfo; config: NpmInfo;
props?: object; props?: Record<string, unknown>;
handler?: (config: EditorConfig) => EditorConfig; handler?: (config: EditorConfig) => EditorConfig;
} }
@ -78,13 +78,13 @@ export interface PluginConfig {
marked?: boolean; marked?: boolean;
align?: 'left' | 'right' | 'top' | 'bottom'; align?: 'left' | 'right' | 'top' | 'bottom';
onClick?: () => void; onClick?: () => void;
dialogProps?: object; dialogProps?: Record<string, unknown>;
balloonProps?: object; balloonProps?: Record<string, unknown>;
panelProps?: object; panelProps?: Record<string, unknown>;
linkProps?: object; linkProps?: Record<string, unknown>;
}; };
config?: NpmInfo; config?: NpmInfo;
pluginProps?: object; pluginProps?: Record<string, unknown>;
} }
export type HooksConfig = HookConfig[]; export type HooksConfig = HookConfig[];
@ -110,7 +110,7 @@ export interface UtilConfig {
content: NpmInfo | ((...args: []) => any); content: NpmInfo | ((...args: []) => any);
} }
export type ConstantsConfig = object; export type ConstantsConfig = Record<string, unknown>;
export interface LifeCyclesConfig { export interface LifeCyclesConfig {
init?: (editor: IEditor) => any; init?: (editor: IEditor) => any;

View File

@ -40,7 +40,7 @@ export type DOMText = string;
export interface ContainerSchema extends NodeSchema { export interface ContainerSchema extends NodeSchema {
componentName: string; // 'Block' | 'Page' | 'Component'; componentName: string; // 'Block' | 'Page' | 'Component';
fileName: string; fileName: string;
meta?: object; meta?: Record<string, unknown>;
state?: { state?: {
[key: string]: CompositeValue; [key: string]: CompositeValue;
}; };

View File

@ -12,7 +12,7 @@ function isReactComponent(obj: any): obj is ComponentType<any> {
export type CustomView = ReactElement | ComponentType<any>; export type CustomView = ReactElement | ComponentType<any>;
export type DynamicProps = (target: SettingTarget) => object; export type DynamicProps = (target: SettingTarget) => Record<string, unknown>;
export type DynamicSetter = (target: SettingTarget) => string | SetterConfig | CustomView; export type DynamicSetter = (target: SettingTarget) => string | SetterConfig | CustomView;
export interface SetterConfig { export interface SetterConfig {
@ -23,7 +23,7 @@ export interface SetterConfig {
/** /**
* the props pass to Setter Component * the props pass to Setter Component
*/ */
props?: object | DynamicProps; props?: Record<string, unknown> | DynamicProps;
children?: any; children?: any;
isRequired?: boolean; isRequired?: boolean;
initialValue?: any | ((target: SettingTarget) => any); initialValue?: any | ((target: SettingTarget) => any);

View File

@ -13,7 +13,7 @@ export interface TitleConfig {
export type TitleContent = string | I18nData | ReactElement | TitleConfig; export type TitleContent = string | I18nData | ReactElement | TitleConfig;
function isPlainObject(value: any): value is object { function isPlainObject(value: any): value is Record<string, unknown> {
if (typeof value !== 'object') { if (typeof value !== 'object') {
return false; return false;
} }