Fix implicit any error for Layout

This commit is contained in:
Wei Zhu 2017-11-21 19:02:23 +08:00
parent e7042ae541
commit dc322a6a9c
2 changed files with 17 additions and 9 deletions

View File

@ -28,6 +28,8 @@ const dimensionMap = {
xl: '1600px',
};
export type CollapseType = 'clickTrigger' | 'responsive';
export interface SiderProps {
style?: React.CSSProperties;
prefixCls?: string;
@ -36,13 +38,19 @@ export interface SiderProps {
collapsed?: boolean;
defaultCollapsed?: boolean;
reverseArrow?: boolean;
onCollapse?: (collapsed: boolean, type: 'clickTrigger' | 'responsive') => void;
onCollapse?: (collapsed: boolean, type: CollapseType) => void;
trigger?: React.ReactNode;
width?: number | string;
collapsedWidth?: number | string;
breakpoint?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
}
export interface SliderState {
collapsed?: boolean;
below: boolean;
belowShow?: boolean;
}
export interface SliderContext {
siderCollapsed: boolean;
}
@ -55,7 +63,7 @@ const generateId = (() => {
};
})();
export default class Sider extends React.Component<SiderProps, any> {
export default class Sider extends React.Component<SiderProps, SliderState> {
static __ANT_LAYOUT_SIDER: any = true;
static defaultProps = {
@ -76,10 +84,10 @@ export default class Sider extends React.Component<SiderProps, any> {
siderHook: PropTypes.object,
};
private mql: any;
private mql: MediaQueryList;
private uniqueId: string;
constructor(props) {
constructor(props: SiderProps) {
super(props);
this.uniqueId = generateId('ant-sider-');
let matchMedia;
@ -107,7 +115,7 @@ export default class Sider extends React.Component<SiderProps, any> {
};
}
componentWillReceiveProps(nextProps) {
componentWillReceiveProps(nextProps: SiderProps) {
if ('collapsed' in nextProps) {
this.setState({
collapsed: nextProps.collapsed,
@ -136,14 +144,14 @@ export default class Sider extends React.Component<SiderProps, any> {
}
}
responsiveHandler = (mql) => {
responsiveHandler = (mql: MediaQueryList) => {
this.setState({ below: mql.matches });
if (this.state.collapsed !== mql.matches) {
this.setCollapsed(mql.matches, 'responsive');
}
}
setCollapsed = (collapsed, type) => {
setCollapsed = (collapsed: boolean, type: CollapseType) => {
if (!('collapsed' in this.props)) {
this.setState({
collapsed,

View File

@ -9,8 +9,8 @@ export interface BasicProps {
className?: string;
}
function generator(props) {
return (BasicComponent): any => {
function generator(props: BasicProps) {
return (BasicComponent: React.ComponentClass<BasicProps>): any => {
return class Adapter extends React.Component<BasicProps, any> {
static Header: any;
static Footer: any;