diff --git a/components/tooltip/Tooltip.tsx b/components/tooltip/Tooltip.tsx index a466b060a..677632c09 100644 --- a/components/tooltip/Tooltip.tsx +++ b/components/tooltip/Tooltip.tsx @@ -56,7 +56,7 @@ export default defineComponent({ }, }, methods: { - handleVisibleChange(visible) { + handleVisibleChange(visible: boolean) { if (!hasProp(this, 'visible')) { this.sVisible = this.isNoTitle() ? false : visible; } @@ -85,7 +85,7 @@ export default defineComponent({ // Fix Tooltip won't hide at disabled button // mouse events don't trigger at disabled button in Chrome // https://github.com/react-component/tooltip/issues/18 - getDisabledCompatibleChildren(ele) { + getDisabledCompatibleChildren(ele: any) { if ( ((typeof ele.type === 'object' && (ele.type.__ANT_BUTTON === true || @@ -143,7 +143,7 @@ export default defineComponent({ }, // 动态设置动画点 - onPopupAlign(domNode, align) { + onPopupAlign(domNode: HTMLElement, align: any) { const placements = this.getPlacements(); // 当前返回的位置 const placement = Object.keys(placements).filter( diff --git a/components/tooltip/placements.ts b/components/tooltip/placements.ts index f1897663e..b529f1e75 100644 --- a/components/tooltip/placements.ts +++ b/components/tooltip/placements.ts @@ -12,7 +12,15 @@ const autoAdjustOverflowDisabled = { const targetOffset = [0, 0]; -export function getOverflowOptions(autoAdjustOverflow) { +interface PlacementsConfig { + arrowPointAtCenter: boolean; + arrowWidth?: number; + verticalArrowShift?: number; + horizontalArrowShift?: number; + autoAdjustOverflow?: boolean | Object; +} + +export function getOverflowOptions(autoAdjustOverflow: boolean | Object) { if (typeof autoAdjustOverflow === 'boolean') { return autoAdjustOverflow ? autoAdjustOverflowEnabled : autoAdjustOverflowDisabled; } @@ -22,7 +30,7 @@ export function getOverflowOptions(autoAdjustOverflow) { }; } -export default function getPlacements(config) { +export default function getPlacements(config: PlacementsConfig) { const { arrowWidth = 5, horizontalArrowShift = 16,