Add explicit types for default props

Fix #8796
Close #8820
This commit is contained in:
Wei Zhu 2018-04-10 10:50:59 +08:00
parent a5e2020908
commit 921361313a
4 changed files with 12 additions and 9 deletions

View File

@ -26,9 +26,11 @@ export interface ClickParam {
export type MenuMode = 'vertical' | 'vertical-left' | 'vertical-right' | 'horizontal' | 'inline'; export type MenuMode = 'vertical' | 'vertical-left' | 'vertical-right' | 'horizontal' | 'inline';
export type MenuTheme = 'light' | 'dark';
export interface MenuProps { export interface MenuProps {
id?: string; id?: string;
theme?: 'light' | 'dark'; theme?: MenuTheme;
mode?: MenuMode; mode?: MenuMode;
selectable?: boolean; selectable?: boolean;
selectedKeys?: Array<string>; selectedKeys?: Array<string>;
@ -63,7 +65,7 @@ export default class Menu extends React.Component<MenuProps, MenuState> {
static defaultProps = { static defaultProps = {
prefixCls: 'ant-menu', prefixCls: 'ant-menu',
className: '', className: '',
theme: 'light', // or dark theme: 'light' as MenuTheme, // or dark
}; };
static childContextTypes = { static childContextTypes = {
inlineCollapsed: PropTypes.bool, inlineCollapsed: PropTypes.bool,

View File

@ -97,7 +97,7 @@ export default class Modal extends React.Component<ModalProps, {}> {
maskTransitionName: 'fade', maskTransitionName: 'fade',
confirmLoading: false, confirmLoading: false,
visible: false, visible: false,
okType: 'primary', okType: 'primary' as ButtonType,
}; };
static propTypes = { static propTypes = {

View File

@ -1,6 +1,5 @@
import * as React from 'react'; import * as React from 'react';
import Tooltip from '../tooltip'; import Tooltip, { AbstractTooltipProps, TooltipPlacement, TooltipTrigger } from '../tooltip';
import { AbstractTooltipProps } from '../tooltip';
import warning from '../_util/warning'; import warning from '../_util/warning';
export interface PopoverProps extends AbstractTooltipProps { export interface PopoverProps extends AbstractTooltipProps {
@ -11,9 +10,9 @@ export interface PopoverProps extends AbstractTooltipProps {
export default class Popover extends React.Component<PopoverProps, {}> { export default class Popover extends React.Component<PopoverProps, {}> {
static defaultProps = { static defaultProps = {
prefixCls: 'ant-popover', prefixCls: 'ant-popover',
placement: 'top', placement: 'top' as TooltipPlacement,
transitionName: 'zoom-big', transitionName: 'zoom-big',
trigger: 'hover', trigger: 'hover' as TooltipTrigger,
mouseEnterDelay: 0.1, mouseEnterDelay: 0.1,
mouseLeaveDelay: 0.1, mouseLeaveDelay: 0.1,
overlayStyle: {}, overlayStyle: {},

View File

@ -12,6 +12,8 @@ export type TooltipPlacement =
'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' |
'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom'; 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom';
export type TooltipTrigger = 'hover' | 'focus' | 'click' | 'contextMenu';
export interface AbstractTooltipProps { export interface AbstractTooltipProps {
prefixCls?: string; prefixCls?: string;
overlayClassName?: string; overlayClassName?: string;
@ -25,7 +27,7 @@ export interface AbstractTooltipProps {
mouseEnterDelay?: number; mouseEnterDelay?: number;
mouseLeaveDelay?: number; mouseLeaveDelay?: number;
transitionName?: string; transitionName?: string;
trigger?: 'hover' | 'focus' | 'click' | 'contextMenu'; trigger?: TooltipTrigger;
openClassName?: string; openClassName?: string;
arrowPointAtCenter?: boolean; arrowPointAtCenter?: boolean;
autoAdjustOverflow?: boolean | AdjustOverflow; autoAdjustOverflow?: boolean | AdjustOverflow;
@ -57,7 +59,7 @@ const splitObject = (obj: any, keys: string[]) => {
export default class Tooltip extends React.Component<TooltipProps, any> { export default class Tooltip extends React.Component<TooltipProps, any> {
static defaultProps = { static defaultProps = {
prefixCls: 'ant-tooltip', prefixCls: 'ant-tooltip',
placement: 'top', placement: 'top' as TooltipPlacement,
transitionName: 'zoom-big-fast', transitionName: 'zoom-big-fast',
mouseEnterDelay: 0.1, mouseEnterDelay: 0.1,
mouseLeaveDelay: 0.1, mouseLeaveDelay: 0.1,