"typescript": "3.2.0-rc"
"@types/react": "16.7.6",
"@types/react-dom": "16.0.9",
import React, { FunctionComponent } from 'react'
type Props = {
onClick: (ev: import('react').MouseEvent<HTMLElement>) => void
children: import('react').ReactChild
color: 'red' | 'green'
}
const Button: FunctionComponent<Props> = ({ onClick: handleClick, color, children }) => (
<button style={{ color }} onClick={handleClick}>
{children}
</button>
)
Button.defaultProps = {
color: 'red'
}
const Test = () => (
<>
/* $ExpectError */
<Button onClick={() => console.log('clicked')}>Click me</Button>
</>
)
@types/reactpackage and had problems.Definitions by:inindex.d.ts) so they can respond.Dependencies:
As stated by @Kovensky
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/test/managedAttributes.tsx#L167-L175
defaultPropsdoesn't properly apply on JSX tag when function component is defined viaFunctionalComponentCode:
Related:
#29816
microsoft/TypeScript#27425