ant-design: type error with react 16.3.1

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

Version

3.3.3

Environment

@types/react 16.3.4 , antd 3.4.0

Reproduction link

https://github.com/whtsky/antd-react-16.3.1-type

Steps to reproduce

npx tsc

What is expected?

compile

What is actually happening?

node_modules/antd/lib/badge/ScrollNumber.d.ts(28,81): error TS2344: Type ‘{ className: string; style: { transition: string | boolean; msTransform: string; WebkitTransform:…’ does not satisfy the constraint ‘HTMLAttributes<HTMLElement>’. Types of property ‘style’ are incompatible. Type ‘{ transition: string | boolean; msTransform: string; WebkitTransform: string; transform: string; }’ is not assignable to type ‘CSSProperties’. Types of property ‘transition’ are incompatible. Type ‘string | boolean’ is not assignable to type ‘string’. Type ‘true’ is not assignable to type ‘string’. node_modules/antd/lib/badge/ScrollNumber.d.ts(38,77): error TS2344: Type ‘{ className: string; style: { transition: string | boolean; msTransform: string; WebkitTransform:…’ does not satisfy the constraint ‘HTMLAttributes<HTMLElement>’. Types of property ‘style’ are incompatible. Type ‘{ transition: string | boolean; msTransform: string; WebkitTransform: string; transform: string; }’ is not assignable to type ‘CSSProperties’. Types of property ‘transition’ are incompatible. Type ‘string | boolean’ is not assignable to type ‘string’. Type ‘true’ is not assignable to type ‘string’.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 16
  • Comments: 23 (9 by maintainers)

Commits related to this issue

Most upvoted comments

as a temporary solution it works to add skipLibCheck flag to tsconfig

@whtsky I don’t see codes in your repo.

@afc163 isn’t it urgent? it is impossible to compile TS+react+antd app

@yesmeck It is antd’s type definition (specifically, ScrollNumber.d.ts) that is incompatible with latest @types/react definition, running tsc will reproduce the issue.

IMO boolean value transition in component’s style props does not make sense, so the latest @types/react is correct, and ScrollNumber.d.ts needs a fix

@yesmeck We don’t need any code to reproduce this problem. Simply import antd will cause type error.

same here

You can try @types/react@~16.2.0 as workaround now.

same here. changing transition: string | boolean; to transition: string; in ScrollNumber.d.ts line 31&41 did it for me though, thanks @KagamiChan .