mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-27 20:49:53 +08:00
Fix implicit any error for Layout
This commit is contained in:
parent
e7042ae541
commit
dc322a6a9c
@ -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,
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user