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

View File

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

View File

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

View File

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