mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-11-30 02:59:04 +08:00
Fix implicit any error for Modal and Message
This commit is contained in:
parent
446977b916
commit
d8f6c3bd8c
@ -3,13 +3,13 @@ import Notification from 'rc-notification';
|
||||
import Icon from '../icon';
|
||||
|
||||
let defaultDuration = 3;
|
||||
let defaultTop;
|
||||
let messageInstance;
|
||||
let defaultTop: number;
|
||||
let messageInstance: any;
|
||||
let key = 1;
|
||||
let prefixCls = 'ant-message';
|
||||
let getContainer;
|
||||
let getContainer: () => HTMLElement;
|
||||
|
||||
function getMessageInstance(callback) {
|
||||
function getMessageInstance(callback: (i: any) => void) {
|
||||
if (messageInstance) {
|
||||
callback(messageInstance);
|
||||
return;
|
||||
@ -19,7 +19,7 @@ function getMessageInstance(callback) {
|
||||
transitionName: 'move-up',
|
||||
style: { top: defaultTop }, // 覆盖原来的样式
|
||||
getContainer,
|
||||
}, (instance) => {
|
||||
}, (instance: any) => {
|
||||
messageInstance = instance;
|
||||
callback(instance);
|
||||
});
|
||||
|
@ -5,13 +5,19 @@ import { ButtonType } from '../button/button';
|
||||
|
||||
export interface ActionButtonProps {
|
||||
type?: ButtonType;
|
||||
actionFn: Function;
|
||||
actionFn?: (...args: any[]) => any | PromiseLike<any>;
|
||||
closeModal: Function;
|
||||
autoFocus?: Boolean;
|
||||
autoFocus?: boolean;
|
||||
}
|
||||
export default class ActionButton extends React.Component<ActionButtonProps, any> {
|
||||
|
||||
export interface ActionButtonState {
|
||||
loading: boolean;
|
||||
}
|
||||
|
||||
export default class ActionButton extends React.Component<ActionButtonProps, ActionButtonState> {
|
||||
timeoutId: number;
|
||||
constructor(props) {
|
||||
|
||||
constructor(props: ActionButtonProps) {
|
||||
super(props);
|
||||
this.state = {
|
||||
loading: false,
|
||||
@ -40,7 +46,7 @@ export default class ActionButton extends React.Component<ActionButtonProps, any
|
||||
}
|
||||
if (ret && ret.then) {
|
||||
this.setState({ loading: true });
|
||||
ret.then((...args) => {
|
||||
ret.then((...args: any[]) => {
|
||||
// It's unnecessary to set loading=false, for the Modal will be unmounted after close.
|
||||
// this.setState({ loading: false });
|
||||
closeModal(...args);
|
||||
|
@ -7,8 +7,8 @@ import { ButtonType } from '../button/button';
|
||||
import LocaleReceiver from '../locale-provider/LocaleReceiver';
|
||||
import { getConfirmLocale } from './locale';
|
||||
|
||||
let mousePosition;
|
||||
let mousePositionEventBinded;
|
||||
let mousePosition: { x: number, y: number } | null;
|
||||
let mousePositionEventBinded: boolean;
|
||||
|
||||
export interface ModalProps {
|
||||
/** 对话框是否可见*/
|
||||
@ -46,11 +46,13 @@ export interface ModalProps {
|
||||
}
|
||||
|
||||
export interface ModalFuncProps {
|
||||
prefixCls?: string;
|
||||
className?: string;
|
||||
visible?: boolean;
|
||||
title?: React.ReactNode | string;
|
||||
content?: React.ReactNode | string;
|
||||
onOk?: (func: Function) => any;
|
||||
onCancel?: (func: Function) => any;
|
||||
title?: React.ReactNode;
|
||||
content?: React.ReactNode;
|
||||
onOk?: (...args: any[]) => any | PromiseLike<any>;
|
||||
onCancel?: (...args: any[]) => any | PromiseLike<any>;
|
||||
width?: string | number;
|
||||
iconClassName?: string;
|
||||
okText?: string;
|
||||
@ -59,12 +61,22 @@ export interface ModalFuncProps {
|
||||
iconType?: string;
|
||||
maskClosable?: boolean;
|
||||
zIndex?: number;
|
||||
okCancel?: boolean;
|
||||
style?: React.CSSProperties;
|
||||
type?: string;
|
||||
}
|
||||
|
||||
export type ModalFunc = (props: ModalFuncProps) => {
|
||||
destroy: () => void,
|
||||
};
|
||||
|
||||
export default class Modal extends React.Component<ModalProps, any> {
|
||||
export interface ModalLocale {
|
||||
okText: string;
|
||||
cancelText: string;
|
||||
justOkText: string;
|
||||
}
|
||||
|
||||
export default class Modal extends React.Component<ModalProps, {}> {
|
||||
static info: ModalFunc;
|
||||
static success: ModalFunc;
|
||||
static error: ModalFunc;
|
||||
@ -97,14 +109,14 @@ export default class Modal extends React.Component<ModalProps, any> {
|
||||
closable: PropTypes.bool,
|
||||
};
|
||||
|
||||
handleCancel = (e) => {
|
||||
handleCancel = (e: React.MouseEvent<HTMLButtonElement>) => {
|
||||
const onCancel = this.props.onCancel;
|
||||
if (onCancel) {
|
||||
onCancel(e);
|
||||
}
|
||||
}
|
||||
|
||||
handleOk = (e) => {
|
||||
handleOk = (e: React.MouseEvent<HTMLButtonElement>) => {
|
||||
const onOk = this.props.onOk;
|
||||
if (onOk) {
|
||||
onOk(e);
|
||||
@ -129,7 +141,7 @@ export default class Modal extends React.Component<ModalProps, any> {
|
||||
mousePositionEventBinded = true;
|
||||
}
|
||||
|
||||
renderFooter = (locale) => {
|
||||
renderFooter = (locale: ModalLocale) => {
|
||||
const { okText, okType, cancelText, confirmLoading } = this.props;
|
||||
return (
|
||||
<div>
|
||||
|
@ -2,12 +2,12 @@ import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import classNames from 'classnames';
|
||||
import Icon from '../icon';
|
||||
import Dialog from './Modal';
|
||||
import Dialog, { ModalFuncProps } from './Modal';
|
||||
import ActionButton from './ActionButton';
|
||||
import { getConfirmLocale } from './locale';
|
||||
|
||||
export default function confirm(config) {
|
||||
const props = {
|
||||
export default function confirm(config: ModalFuncProps) {
|
||||
const props: ModalFuncProps = {
|
||||
iconType: 'question-circle',
|
||||
okType: 'primary',
|
||||
...config,
|
||||
@ -33,7 +33,7 @@ export default function confirm(config) {
|
||||
(props.okCancel ? runtimeLocale.okText : runtimeLocale.justOkText);
|
||||
props.cancelText = props.cancelText || runtimeLocale.cancelText;
|
||||
|
||||
function close(...args) {
|
||||
function close(...args: any[]) {
|
||||
const unmountResult = ReactDOM.unmountComponentAtNode(div);
|
||||
if (unmountResult && div.parentNode) {
|
||||
div.parentNode.removeChild(div);
|
||||
@ -47,7 +47,7 @@ export default function confirm(config) {
|
||||
|
||||
let body = (
|
||||
<div className={`${prefixCls}-body`}>
|
||||
<Icon type={props.iconType} />
|
||||
<Icon type={props.iconType!} />
|
||||
<span className={`${prefixCls}-title`}>{props.title}</span>
|
||||
<div className={`${prefixCls}-content`}>{props.content}</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user