Fix type errors

Close #9988
This commit is contained in:
Wei Zhu 2018-04-11 12:01:28 +08:00
parent 0437d858f2
commit 2a5479a524
6 changed files with 11 additions and 6 deletions

View File

@ -221,7 +221,8 @@ export default class Anchor extends React.Component<AnchorProps, any> {
return; return;
} }
const { prefixCls } = this.props; const { prefixCls } = this.props;
const linkNode = ReactDOM.findDOMNode(this as any).getElementsByClassName(`${prefixCls}-link-title-active`)[0]; const anchorNode = ReactDOM.findDOMNode(this) as Element;
const linkNode = anchorNode.getElementsByClassName(`${prefixCls}-link-title-active`)[0];
if (linkNode) { if (linkNode) {
this.inkNode.style.top = `${(linkNode as any).offsetTop + linkNode.clientHeight / 2 - 4.5}px`; this.inkNode.style.top = `${(linkNode as any).offsetTop + linkNode.clientHeight / 2 - 4.5}px`;
} }

View File

@ -55,7 +55,8 @@ export default class Avatar extends React.Component<AvatarProps, AvatarState> {
const childrenNode = this.avatarChildren; const childrenNode = this.avatarChildren;
if (childrenNode) { if (childrenNode) {
const childrenWidth = childrenNode.offsetWidth; const childrenWidth = childrenNode.offsetWidth;
const avatarWidth = ReactDOM.findDOMNode(this).getBoundingClientRect().width; const avatarNode = ReactDOM.findDOMNode(this) as Element;
const avatarWidth = avatarNode.getBoundingClientRect().width;
// add 4px gap for each side to get better performance // add 4px gap for each side to get better performance
if (avatarWidth - 8 < childrenWidth) { if (avatarWidth - 8 < childrenWidth) {
this.setState({ this.setState({

View File

@ -248,7 +248,8 @@ export default class FormItem extends React.Component<FormItemProps, any> {
if (typeof label === 'string') { if (typeof label === 'string') {
e.preventDefault(); e.preventDefault();
} }
const control = ReactDOM.findDOMNode(this).querySelector(`[id="${id}"]`) as HTMLElement; const formItemNode = ReactDOM.findDOMNode(this) as Element;
const control = formItemNode.querySelector(`[id="${id}"]`) as HTMLElement;
if (control && control.focus) { if (control && control.focus) {
control.focus(); control.focus();
} }

View File

@ -121,8 +121,9 @@ export default class Menu extends React.Component<MenuProps, MenuState> {
} }
if ((nextProps.inlineCollapsed && !this.props.inlineCollapsed) || if ((nextProps.inlineCollapsed && !this.props.inlineCollapsed) ||
(nextContext.siderCollapsed && !this.context.siderCollapsed)) { (nextContext.siderCollapsed && !this.context.siderCollapsed)) {
const menuNode = findDOMNode(this) as Element;
this.switchModeFromInline = this.switchModeFromInline =
!!this.state.openKeys.length && !!findDOMNode(this).querySelectorAll(`.${prefixCls}-submenu-open`).length; !!this.state.openKeys.length && !!menuNode.querySelectorAll(`.${prefixCls}-submenu-open`).length;
this.inlineOpenKeys = this.state.openKeys; this.inlineOpenKeys = this.state.openKeys;
this.setState({ openKeys: [] }); this.setState({ openKeys: [] });
} }

View File

@ -79,7 +79,7 @@ export default class Tabs extends React.Component<TabsProps, any> {
componentDidMount() { componentDidMount() {
const NO_FLEX = ' no-flex'; const NO_FLEX = ' no-flex';
const tabNode = ReactDOM.findDOMNode(this); const tabNode = ReactDOM.findDOMNode(this) as Element;
if (tabNode && !isFlexSupported() && tabNode.className.indexOf(NO_FLEX) === -1) { if (tabNode && !isFlexSupported() && tabNode.className.indexOf(NO_FLEX) === -1) {
tabNode.className += NO_FLEX; tabNode.className += NO_FLEX;
} }

View File

@ -101,7 +101,8 @@ export default class TransferList extends React.Component<TransferListProps, any
// Manually trigger scroll event for lazy search bug // Manually trigger scroll event for lazy search bug
// https://github.com/ant-design/ant-design/issues/5631 // https://github.com/ant-design/ant-design/issues/5631
this.triggerScrollTimer = window.setTimeout(() => { this.triggerScrollTimer = window.setTimeout(() => {
const listNode = ReactDOM.findDOMNode(this).querySelectorAll('.ant-transfer-list-content')[0]; const transferNode = ReactDOM.findDOMNode(this) as Element;
const listNode = transferNode.querySelectorAll('.ant-transfer-list-content')[0];
if (listNode) { if (listNode) {
triggerEvent(listNode, 'scroll'); triggerEvent(listNode, 'scroll');
} }