Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Export tooltip helper interfaces #19846

merged 1 commit into from Nov 21, 2019


Copy link

@kachkaev kachkaev commented Nov 20, 2019

πŸ€” This is a ...

  • New feature
  • Bug fix
  • Site / document update
  • Component style update
  • TypeScript definition update
  • Refactoring
  • Code style optimization
  • Test Case
  • Branch merge
  • Other (about what?)

πŸ”— Related issue link

πŸ’‘ Background and solution

We have a library that re-exports a few ant-design components. Following an upgrade from antd 3.20.0 to 3.25.0, we noticed a typescript error in this code:

// CustomTooltip.tsx
import "antd/lib/tooltip/style"
import "./CustomTooltip.less"

import AntdTooltip, { TooltipPlacement, TooltipProps } from "antd/lib/tooltip"
import classnames from "classnames"
import React from "react"

const CustomTooltip: React.RefForwardingComponent<AntdTooltip, TooltipProps> = (
  { overlayClassName, },
) => {
  return (
      overlayClassName={classnames("custom-tooltip-overlay", overlayClassName)}
export default React.forwardRef(CustomTooltip)
// ⬆
// ❌ Default export of the module has or is using private name 'TooltipPropsWithTitle'.ts(4082)
// ❌ Default export of the module has or is using private name 'TooltipPropsWithOverlay'.ts(4082)
export { TooltipProps, TooltipPlacement }

This seems to happen only when we have this option in our tsconfig.json:

  "compilerOptions": {
    "declaration": true,

After adding export in front of TooltipPropsWithTitle and TooltipPropsWithOverlay things work perfectly!

Seems like the problem was introduced in #18515 /cc @laysent

πŸ“ Changelog

Language Changelog
πŸ‡ΊπŸ‡Έ English Export tooltop helper interfaces to fix an issue with generating TypeScript declarations
πŸ‡¨πŸ‡³ Chinese

β˜‘οΈ Self Check before Merge

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed
    need help with Chinese

Copy link

netlify bot commented Nov 20, 2019

Deploy preview for ant-design ready!

Built with commit 2e21137

Copy link

codesandbox-ci bot commented Nov 20, 2019

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 2e21137:

Sandbox Source
antd reproduction template Configuration

Copy link

codecov bot commented Nov 20, 2019

Codecov Report

Merging #19846 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #19846   +/-   ##
  Coverage    97.8%    97.8%           
  Files         284      284           
  Lines        7705     7705           
  Branches     2165     2165           
  Hits         7536     7536           
  Misses        169      169
Impacted Files Coverage Ξ”
components/tooltip/index.tsx 96.62% <ΓΈ> (ΓΈ) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Ξ” = absolute <relative> (impact), ΓΈ = not affected, ? = missing data
Powered by Codecov. Last update 3072787...2e21137. Read the comment docs.

Copy link

yoyo837 commented Nov 21, 2019

Can you solve your problem with type TooltipProps?

export declare type TooltipProps = TooltipPropsWithTitle | TooltipPropsWithOverlay;

and /cc @laysent

Copy link

laysent commented Nov 21, 2019

lgtm. All used interfaces should be exported, otherwise --declaration won't work. my bad.
(explanation of this behavior can be found here: microsoft/TypeScript#6307 (comment))

@yoyo837 yoyo837 changed the title Export tooltop helper interfaces fix: Export tooltip helper interfaces Nov 21, 2019
@auto-add-label auto-add-label bot added the bug label Nov 21, 2019
@yoyo837 yoyo837 merged commit 5ff3a77 into ant-design:master Nov 21, 2019
@ycjcl868 ycjcl868 mentioned this pull request Nov 25, 2019
14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

3 participants