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
merged 1 commit into from Nov 21, 2019

Conversation

@kachkaev
Copy link
Contributor

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, ...rest },
  ref,
) => {
  return (
    <AntdTooltip
      ref={ref}
      overlayClassName={classnames("custom-tooltip-overlay", overlayClassName)}
      {...rest}
    />
  )
}
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
@pr-triage pr-triage bot added the PR: unreviewed label Nov 20, 2019
@netlify

This comment has been minimized.

Copy link

netlify bot commented Nov 20, 2019

Deploy preview for ant-design ready!

Built with commit 2e21137

https://deploy-preview-19846--ant-design.netlify.com

@codesandbox

This comment has been minimized.

Copy link

codesandbox 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
@codecov

This comment has been minimized.

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.

@yoyo837

This comment has been minimized.

Copy link
Collaborator

yoyo837 commented Nov 21, 2019

Can you solve your problem with type TooltipProps?

export declare type TooltipProps = TooltipPropsWithTitle | TooltipPropsWithOverlay;

and /cc @laysent

@laysent

This comment has been minimized.

Copy link
Contributor

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
28 checks passed
28 checks passed
Header rules - ant-design No header rules processed
Details
Pages changed - ant-design 217 new files uploaded
Details
DEP All dependencies are resolved
Mixed content - ant-design No mixed content detected
Details
Redirect rules - ant-design 18 redirect rules processed
Details
Semantic Pull Request ready to be squashed
Details
WIP Ready for review
Details
buildsize No change
Details
ci/circleci: check_metadata Your tests passed on CircleCI!
Details
ci/circleci: compile Your tests passed on CircleCI!
Details
ci/circleci: dist Your tests passed on CircleCI!
Details
ci/circleci: lint Your tests passed on CircleCI!
Details
ci/circleci: setup Your tests passed on CircleCI!
Details
ci/circleci: test_dist Your tests passed on CircleCI!
Details
ci/circleci: test_dist_15 Your tests passed on CircleCI!
Details
ci/circleci: test_dom Your tests passed on CircleCI!
Details
ci/circleci: test_dom_15 Your tests passed on CircleCI!
Details
ci/circleci: test_es Your tests passed on CircleCI!
Details
ci/circleci: test_es_15 Your tests passed on CircleCI!
Details
ci/circleci: test_lib Your tests passed on CircleCI!
Details
ci/circleci: test_lib_15 Your tests passed on CircleCI!
Details
ci/circleci: test_node Your tests passed on CircleCI!
Details
ci/circleci: test_node_15 Your tests passed on CircleCI!
Details
ci/codesandbox Building packages succeeded.
Details
codecov/patch Coverage not affected when comparing 3072787...2e21137
Details
codecov/project 97.8% remains the same compared to 3072787
Details
netlify/ant-design/deploy-preview Deploy preview ready!
Details
security/snyk - package.json (paranoidjk) No manifest changes detected
@pr-triage pr-triage bot added PR: merged and removed PR: unreviewed labels Nov 21, 2019
@ycjcl868 ycjcl868 mentioned this pull request Nov 25, 2019
1 of 14 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.