Merge pull request #17249 from ant-design/revert-form-type

fix: revert `unknown` to `any`
This commit is contained in:
偏右 2019-06-24 12:02:19 +08:00 committed by GitHub
commit f6121aa1cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 68 additions and 75 deletions

View File

@ -2,7 +2,7 @@ import * as React from 'react';
import * as ReactDOM from 'react-dom';
export interface InputElementProps {
children: React.ReactElement<unknown>;
children: React.ReactElement<any>;
}
export default class InputElement extends React.Component<InputElementProps, any> {

View File

@ -17,8 +17,8 @@ export type DataSourceItemType =
| React.ReactElement<OptGroupProps>;
export interface AutoCompleteInputProps {
onChange?: React.FormEventHandler<unknown>;
value: unknown;
onChange?: React.FormEventHandler<any>;
value: any;
}
export type ValidInputElement =
@ -34,7 +34,7 @@ export interface AutoCompleteProps extends AbstractSelectProps {
backfill?: boolean;
optionLabelProp?: string;
onChange?: (value: SelectValue) => void;
onSelect?: (value: SelectValue, option: Object) => unknown;
onSelect?: (value: SelectValue, option: Object) => any;
onBlur?: (value: SelectValue) => void;
onFocus?: () => void;
children?:

View File

@ -17,11 +17,11 @@ export interface Route {
export interface BreadcrumbProps {
prefixCls?: string;
routes?: Route[];
params?: unknown;
params?: any;
separator?: React.ReactNode;
itemRender?: (
route: Route,
params: unknown,
params: any,
routes: Array<Route>,
paths: Array<string>,
) => React.ReactNode;

View File

@ -93,13 +93,13 @@ export type AnchorButtonProps = {
target?: string;
onClick?: React.MouseEventHandler<HTMLElement>;
} & BaseButtonProps &
Omit<React.AnchorHTMLAttributes<unknown>, 'type' | 'onClick'>;
Omit<React.AnchorHTMLAttributes<any>, 'type' | 'onClick'>;
export type NativeButtonProps = {
htmlType?: ButtonHTMLType;
onClick?: React.MouseEventHandler<HTMLElement>;
} & BaseButtonProps &
Omit<React.ButtonHTMLAttributes<unknown>, 'type' | 'onClick'>;
Omit<React.ButtonHTMLAttributes<any>, 'type' | 'onClick'>;
export type ButtonProps = Partial<AnchorButtonProps & NativeButtonProps>;

View File

@ -20,7 +20,7 @@ export interface AbstractCheckboxProps<T> {
onMouseLeave?: React.MouseEventHandler<HTMLElement>;
onKeyPress?: React.KeyboardEventHandler<HTMLElement>;
onKeyDown?: React.KeyboardEventHandler<HTMLElement>;
value?: unknown;
value?: any;
tabIndex?: number;
name?: string;
children?: React.ReactNode;

View File

@ -39,7 +39,7 @@ export interface CheckboxGroupState {
export interface CheckboxGroupContext {
checkboxGroup: {
toggleOption: (option: CheckboxOptionType) => void;
value: unknown;
value: any;
disabled: boolean;
};
}

View File

@ -16,7 +16,7 @@ export interface PickerProps {
style?: React.CSSProperties;
popupStyle?: React.CSSProperties;
dropdownClassName?: string;
locale?: unknown;
locale?: any;
size?: 'large' | 'small' | 'default';
getCalendarContainer?: (triggerNode: Element) => HTMLElement;
open?: boolean;

View File

@ -13,15 +13,15 @@ import { FIELD_META_PROP, FIELD_DATA_PROP } from './constants';
import { FormContext } from './context';
import { FormWrappedProps } from './interface';
type FormCreateOptionMessagesCallback = (...args: unknown[]) => string;
type FormCreateOptionMessagesCallback = (...args: any[]) => string;
interface FormCreateOptionMessages {
[messageId: string]: string | FormCreateOptionMessagesCallback | FormCreateOptionMessages;
}
export interface FormCreateOption<T> {
onFieldsChange?: (props: T, fields: unknown, allFields: unknown) => void;
onValuesChange?: (props: T, changedValues: unknown, allValues: unknown) => void;
onFieldsChange?: (props: T, fields: any, allFields: any) => void;
onValuesChange?: (props: T, changedValues: any, allValues: any) => void;
mapPropsToFields?: (props: T) => void;
validateMessages?: FormCreateOptionMessages;
withRef?: boolean;
@ -71,30 +71,24 @@ export type ValidationRule = {
/** validate from a regular expression */
pattern?: RegExp;
/** transform a value before validation */
transform?: (value: unknown) => unknown;
transform?: (value: any) => any;
/** custom validate function (Note: callback must be called) */
validator?: (
rule: unknown,
value: unknown,
callback: unknown,
source?: unknown,
options?: unknown,
) => unknown;
validator?: (rule: any, value: any, callback: any, source?: any, options?: any) => any;
};
export type ValidateCallback<V> = (errors: unknown, values: V) => void;
export type ValidateCallback<V> = (errors: any, values: V) => void;
export type GetFieldDecoratorOptions = {
/** 子节点的值的属性,如 Checkbox 的是 'checked' */
valuePropName?: string;
/** 子节点的初始值,类型、可选值均由子节点决定 */
initialValue?: unknown;
initialValue?: any;
/** 收集子节点的值的时机 */
trigger?: string;
/** 可以把 onChange 的参数转化为控件的值,例如 DatePicker 可设为:(date, dateString) => dateString */
getValueFromEvent?: (...args: unknown[]) => unknown;
getValueFromEvent?: (...args: any[]) => any;
/** Get the component props according to field value. */
getValueProps?: (value: unknown) => unknown;
getValueProps?: (value: any) => any;
/** 校验子节点值的时机 */
validateTrigger?: string | string[];
/** 校验规则,参见 [async-validator](https://github.com/yiminghe/async-validator) */
@ -102,7 +96,7 @@ export type GetFieldDecoratorOptions = {
/** 是否和其他控件互斥,特别用于 Radio 单选控件 */
exclusive?: boolean;
/** Normalize value to form component */
normalize?: (value: unknown, prevValue: unknown, allValues: unknown) => unknown;
normalize?: (value: any, prevValue: any, allValues: any) => any;
/** Whether stop validate on first rule of error for this field. */
validateFirst?: boolean;
/** 是否一直保留子节点的信息 */
@ -141,11 +135,11 @@ export type ValidateFieldsOptions = {
};
// function create
export type WrappedFormUtils<V = unknown> = {
export type WrappedFormUtils<V = any> = {
/** 获取一组输入控件的值,如不传入参数,则获取全部组件的值 */
getFieldsValue(fieldNames?: Array<string>): { [field: string]: unknown };
getFieldsValue(fieldNames?: Array<string>): { [field: string]: any };
/** 获取一个输入控件的值 */
getFieldValue(fieldName: string): unknown;
getFieldValue(fieldName: string): any;
/** 设置一组输入控件的值 */
setFieldsValue(obj: Object): void;
/** 设置一组输入控件的值 */
@ -192,17 +186,15 @@ export type WrappedFormUtils<V = unknown> = {
): (node: React.ReactNode) => React.ReactNode;
};
export interface WrappedFormInternalProps<V = unknown> {
export interface WrappedFormInternalProps<V = any> {
form: WrappedFormUtils<V>;
}
export interface RcBaseFormProps {
wrappedComponentRef?: unknown;
wrappedComponentRef?: any;
}
export interface FormComponentProps<V = unknown>
extends WrappedFormInternalProps<V>,
RcBaseFormProps {
export interface FormComponentProps<V = any> extends WrappedFormInternalProps<V>, RcBaseFormProps {
form: WrappedFormUtils<V>;
}

View File

@ -5,7 +5,7 @@ const customCache = new Set<string>();
export interface CustomIconOptions {
scriptUrl?: string;
extraCommonProps?: { [key: string]: unknown };
extraCommonProps?: { [key: string]: any };
}
export default function create(options: CustomIconOptions = {}): React.SFC<IconProps> {

View File

@ -14,14 +14,14 @@ export interface MentionProps {
prefixCls?: string;
suggestionStyle?: React.CSSProperties;
defaultSuggestions?: Array<SuggestionItme>;
suggestions?: Array<React.ReactElement<unknown>>;
onSearchChange?: (value: string, trigger: string) => unknown;
onChange?: (contentState: unknown) => void;
notFoundContent?: unknown;
suggestions?: Array<React.ReactElement<any>>;
onSearchChange?: (value: string, trigger: string) => any;
onChange?: (contentState: any) => void;
notFoundContent?: any;
loading?: boolean;
style?: React.CSSProperties;
defaultValue?: unknown;
value?: unknown;
defaultValue?: any;
value?: any;
className?: string;
multiLines?: boolean;
prefix?: string | string[];
@ -29,14 +29,14 @@ export interface MentionProps {
getSuggestionContainer?: (triggerNode: Element) => HTMLElement;
onFocus?: React.FocusEventHandler<HTMLElement>;
onBlur?: React.FocusEventHandler<HTMLElement>;
onSelect?: (suggestion: string, data?: unknown) => void;
onSelect?: (suggestion: string, data?: any) => void;
readOnly?: boolean;
disabled?: boolean;
placement?: MentionPlacement;
}
export interface MentionState {
filteredSuggestions?: Array<unknown>;
filteredSuggestions?: Array<any>;
focus?: Boolean;
}

View File

@ -19,7 +19,7 @@ export type MentionPlacement = 'top' | 'bottom';
export interface OptionProps {
value: string;
children: React.ReactNode;
[key: string]: unknown;
[key: string]: any;
}
export interface MentionProps extends RcMentionsProps {

View File

@ -15,7 +15,7 @@ import raf from '../_util/raf';
export interface SelectParam {
key: string;
keyPath: Array<string>;
item: unknown;
item: any;
domEvent: Event;
selectedKeys: Array<string>;
}
@ -23,7 +23,7 @@ export interface SelectParam {
export interface ClickParam {
key: string;
keyPath: Array<string>;
item: unknown;
item: any;
domEvent: Event;
}

View File

@ -39,7 +39,7 @@ function getMessageInstance(callback: (i: any) => void) {
type NoticeType = 'info' | 'success' | 'error' | 'warning' | 'loading';
export interface ThenableArgument {
(val: unknown): void;
(val: any): void;
}
export interface MessageType {

View File

@ -74,7 +74,7 @@ export interface ModalProps {
maskStyle?: React.CSSProperties;
mask?: boolean;
keyboard?: boolean;
wrapProps?: unknown;
wrapProps?: any;
prefixCls?: string;
}
@ -85,8 +85,8 @@ export interface ModalFuncProps {
title?: React.ReactNode;
content?: React.ReactNode;
// TODO: find out exact types
onOk?: (...args: unknown[]) => unknown;
onCancel?: (...args: unknown[]) => unknown;
onOk?: (...args: any[]) => any;
onCancel?: (...args: any[]) => any;
okButtonProps?: NativeButtonProps;
cancelButtonProps?: NativeButtonProps;
centered?: boolean;
@ -214,7 +214,7 @@ export default class Modal extends React.Component<ModalProps, {}> {
const closeIcon = (
<span className={`${prefixCls}-close-x`}>
<Icon className={`${prefixCls}-close-icon`} type={'close'} />
<Icon className={`${prefixCls}-close-icon`} type="close" />
</span>
);

View File

@ -5,8 +5,8 @@ import { AbstractCheckboxProps } from '../checkbox/Checkbox';
export type RadioGroupButtonStyle = 'outline' | 'solid';
export interface RadioGroupProps extends AbstractCheckboxGroupProps {
defaultValue?: unknown;
value?: unknown;
defaultValue?: any;
value?: any;
onChange?: (e: RadioChangeEvent) => void;
size?: 'large' | 'default' | 'small';
onMouseEnter?: React.MouseEventHandler<HTMLDivElement>;
@ -18,13 +18,13 @@ export interface RadioGroupProps extends AbstractCheckboxGroupProps {
}
export interface RadioGroupState {
value: unknown;
value: any;
}
export interface RadioGroupContext {
radioGroup: {
onChange: React.ChangeEventHandler<HTMLInputElement>;
value: unknown;
value: any;
disabled: boolean;
name: string;
};

View File

@ -59,9 +59,9 @@ export interface SelectProps<T = SelectValue> extends AbstractSelectProps {
firstActiveValue?: string | string[];
onChange?: (
value: T,
option: React.ReactElement<unknown> | React.ReactElement<unknown>[],
option: React.ReactElement<any> | React.ReactElement<any>[],
) => void;
onSelect?: (value: T extends (infer I)[] ? I : T, option: React.ReactElement<unknown>) => void;
onSelect?: (value: T extends (infer I)[] ? I : T, option: React.ReactElement<any>) => void;
onDeselect?: (value: T extends (infer I)[] ? I : T) => void;
onBlur?: (value: T) => void;
onFocus?: () => void;
@ -75,7 +75,7 @@ export interface SelectProps<T = SelectValue> extends AbstractSelectProps {
optionFilterProp?: string;
labelInValue?: boolean;
tokenSeparators?: string[];
getInputElement?: () => React.ReactElement<unknown>;
getInputElement?: () => React.ReactElement<any>;
autoFocus?: boolean;
suffixIcon?: React.ReactNode;
removeIcon?: React.ReactNode;

View File

@ -43,7 +43,7 @@ import warning from '../_util/warning';
function noop() {}
function stopPropagation(e: React.SyntheticEvent<unknown>) {
function stopPropagation(e: React.SyntheticEvent<any>) {
e.stopPropagation();
if (e.nativeEvent.stopImmediatePropagation) {
e.nativeEvent.stopImmediatePropagation();

View File

@ -13,7 +13,7 @@ import FilterDropdownMenuWrapper from './FilterDropdownMenuWrapper';
import { FilterMenuProps, FilterMenuState, ColumnProps, ColumnFilterItem } from './interface';
import { generateValueMaps } from './util';
function stopPropagation(e: React.SyntheticEvent<unknown>) {
function stopPropagation(e: React.SyntheticEvent<any>) {
e.stopPropagation();
if (e.nativeEvent.stopImmediatePropagation) {
e.nativeEvent.stopImmediatePropagation();

View File

@ -29,10 +29,10 @@ export interface ColumnProps<T> {
| ((options: { filters: TableStateFilters; sortOrder?: SortOrder }) => React.ReactNode);
key?: React.Key;
dataIndex?: string; // Note: We can not use generic type here, since we need to support nested key, see #9393
render?: (text: unknown, record: T, index: number) => React.ReactNode;
render?: (text: any, record: T, index: number) => React.ReactNode;
align?: 'left' | 'right' | 'center';
filters?: ColumnFilterItem[];
onFilter?: (value: unknown, record: T) => boolean;
onFilter?: (value: any, record: T) => boolean;
filterMultiple?: boolean;
filterDropdown?: React.ReactNode | ((props: FilterDropdownProps) => React.ReactNode);
filterDropdownVisible?: boolean;
@ -44,7 +44,7 @@ export interface ColumnProps<T> {
className?: string;
fixed?: boolean | ('left' | 'right');
filterIcon?: React.ReactNode | ((filtered: boolean) => React.ReactNode);
filteredValue?: unknown[];
filteredValue?: any[];
sortOrder?: SortOrder | boolean;
children?: ColumnProps<T>[];
onCellClick?: (record: T, event: Event) => void;
@ -135,6 +135,7 @@ export interface TableEventListeners {
onContextMenu?: (arg: React.SyntheticEvent) => void;
onMouseEnter?: (arg: React.SyntheticEvent) => void;
onMouseLeave?: (arg: React.SyntheticEvent) => void;
[name: string]: any; // https://github.com/ant-design/ant-design/issues/17245#issuecomment-504807714
}
export interface TableProps<T> {
@ -218,7 +219,7 @@ export interface SelectionCheckboxAllProps<T> {
getRecordKey: (record: T, index?: number) => string;
data: T[];
prefixCls: string | undefined;
onSelect: (key: string, index: number, selectFunc: unknown) => void;
onSelect: (key: string, index: number, selectFunc: any) => void;
hideDefaultSelections?: boolean;
selections?: SelectionItem[] | boolean;
getPopupContainer?: GetPopupContainer;
@ -255,7 +256,7 @@ export interface FilterMenuProps<T> {
locale: TableLocale;
selectedKeys: string[];
column: ColumnProps<T>;
confirmFilter: (column: ColumnProps<T>, selectedKeys: string[]) => unknown;
confirmFilter: (column: ColumnProps<T>, selectedKeys: string[]) => any;
prefixCls: string;
dropdownPrefixCls: string;
getPopupContainer?: GetPopupContainer;

View File

@ -31,7 +31,7 @@ export interface TabsProps {
className?: string;
animated?: boolean | { inkBar: boolean; tabPane: boolean };
tabBarGutter?: number;
renderTabBar?: (props: TabsProps, DefaultTabBar: React.ReactNode) => React.ReactElement<unknown>;
renderTabBar?: (props: TabsProps, DefaultTabBar: React.ReactNode) => React.ReactElement<any>;
destroyInactiveTabPane?: boolean;
}

View File

@ -35,16 +35,16 @@ export interface TreeSelectProps<T extends TreeNodeValue> extends AbstractSelect
autoFocus?: boolean;
defaultValue?: T;
dropdownStyle?: React.CSSProperties;
filterTreeNode?: (inputValue: string, treeNode: unknown) => boolean | boolean;
filterTreeNode?: (inputValue: string, treeNode: any) => boolean | boolean;
labelInValue?: boolean;
loadData?: (node: unknown) => void;
loadData?: (node: any) => void;
maxTagCount?: number;
maxTagPlaceholder?: React.ReactNode | ((omittedValues: unknown[]) => React.ReactNode);
maxTagPlaceholder?: React.ReactNode | ((omittedValues: any[]) => React.ReactNode);
multiple?: boolean;
notFoundContent?: React.ReactNode;
onChange?: (value: T, label: unknown, extra: unknown) => void;
onSearch?: (value: unknown) => void;
onSelect?: (value: unknown) => void;
onChange?: (value: T, label: any, extra: any) => void;
onSearch?: (value: any) => void;
onSelect?: (value: any) => void;
onTreeExpand?: (keys: Array<string>) => void;
onFocus?: React.FocusEventHandler<HTMLInputElement>;
onBlur?: React.FocusEventHandler<HTMLInputElement>;

View File

@ -148,7 +148,7 @@ export interface TreeProps {
style?: React.CSSProperties;
showIcon?: boolean;
icon?: ((nodeProps: AntdTreeNodeAttribute) => React.ReactNode) | React.ReactNode;
switcherIcon?: React.ReactElement<unknown>;
switcherIcon?: React.ReactElement<any>;
prefixCls?: string;
filterTreeNode?: (node: AntTreeNode) => boolean;
children?: React.ReactNode;

View File

@ -134,7 +134,7 @@
"eslint-plugin-jest": "^22.6.4",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-markdown": "~1.0.0",
"eslint-plugin-react": "^7.13.0",
"eslint-plugin-react": "~7.13.0",
"eslint-tinker": "^0.5.0",
"fetch-jsonp": "^1.1.3",
"glob": "^7.1.4",