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

Button.d.ts seems incorrect. Error: "Types of property 'ref' are incompatible." #10405

Closed
cdeutsch opened this Issue May 7, 2018 · 4 comments

Comments

Projects
None yet
3 participants
@cdeutsch
Contributor

cdeutsch commented May 7, 2018

  • I have searched the issues of this repository and believe that this is not a duplicate.

Version

3.5.0

Environment

OSX, Chrome

Reproduction link

https://github.com/cdeutsch/antd-issue/
See reproduction below as well.

Steps to reproduce

See the code and error in MyButton.tsx in reproduction.

What is expected?

You should be able to spread all ButtonProps to a Button component.

What is actually happening?

ButtonProps contains incorrect properties.


The bug was introduced in #10229 /cc @whtsky

@yesmeck

This comment has been minimized.

Member

yesmeck commented May 8, 2018

@yesmeck yesmeck closed this May 8, 2018

@cdeutsch

This comment has been minimized.

Contributor

cdeutsch commented May 8, 2018

@yesmeck I have the latest @types/react

I think we may just need to omit ref from the BaseButtonProps<T> definition:
Omit<Omit<React.HTMLProps<T>, 'size'>, 'ref'>

/cc @whtsky

Here's a better reproduction:
https://github.com/cdeutsch/antd-issue/blob/f13d916cc911789f2675ad9c023403847c42782f/src/MyButton.tsx#L12

image

There are issues just trying to set a ref:
https://github.com/cdeutsch/antd-issue/blob/f13d916cc911789f2675ad9c023403847c42782f/src/MyThingWithRef.tsx#L10

image

cdeutsch added a commit to cdeutsch/ant-design that referenced this issue May 8, 2018

@yesmeck yesmeck reopened this May 9, 2018

@frantic1048

This comment has been minimized.

frantic1048 commented May 9, 2018

Why not use React.createRef<Button>() instead but React.createRef<HTMLAnchorElement>() ? The ref is used on a Button, not HTMLAnchorElement. (notice the last line of the type hint: "Property 'timeout' is missing in type 'HTMLAnchorElement'") @cdeutsch

@cdeutsch

This comment has been minimized.

Contributor

cdeutsch commented May 9, 2018

@frantic1048 I've tried all combinations. They all throw the error.

cdeutsch added a commit to cdeutsch/ant-design that referenced this issue May 9, 2018

yesmeck added a commit that referenced this issue May 10, 2018

bors bot added a commit to mozilla/delivery-console that referenced this issue May 14, 2018

Merge #160
160: Update dependency antd to v3.5.2 r=rehandalal a=renovate[bot]

This Pull Request updates dependency [antd](https://github.com/ant-design/ant-design) from `v3.5.1` to `v3.5.2`



<details>
<summary>Release Notes</summary>

### [`v3.5.2`](https://github.com/ant-design/ant-design/releases/3.5.2)
[Compare Source](ant-design/ant-design@3.5.1...3.5.2)
- 🐞 Fixed `Cascader` displayRender z-index issue. [#&#8203;10433](`ant-design/ant-design#10433)
- 🐞 Fixed `Button` Types of property 'ref' are incompatible. [#&#8203;10405](`ant-design/ant-design#10405)
- 🐞 Fixed `Table` filter doesn't work on checkbox click. [#&#8203;10452](`ant-design/ant-design#10452)
- 🐞 Fixed the height of `Form` item when checks position is dithered. [#&#8203;10445](`ant-design/ant-design#10445)
- 🌟 Allow to use any CSS units for `Layout` width. [#&#8203;10479](`ant-design/ant-design#10479)


---


- 🐞 修复 `Cascader` 的 displayRender 问题。[#&#8203;10433](`ant-design/ant-design#10433)
- 🐞 修复 `Button` ref 不兼容问题。[#&#8203;10405](`ant-design/ant-design#10405)
- 🐞 修复 `Table` 过滤器在复选框上不起作用。[#&#8203;10452](`ant-design/ant-design#10452)
- 🐞 修复 `Form` 表单项校验位置高度时出现抖动问题。[#&#8203;10445](`ant-design/ant-design#10445)
- 🌟 设置 `Layout` 宽度时,允许使用任何的 CSS 单位。 [#&#8203;10479](`ant-design/ant-design#10479)

---

</details>




---

This PR has been generated by [Renovate Bot](https://renovatebot.com).

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment