@types/react
package and had problems.Definitions by:
in index.d.ts
) so they can respond.
Dependencies:
"typescript": "3.2.0-rc"
"@types/react": "16.7.6",
"@types/react-dom": "16.0.9",
As stated by @Kovensky
defaultProps
doesn't properly apply on JSX tag when function component is defined via FunctionalComponent
Code:
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> </> )
Related:
#29816
microsoft/TypeScript#27425
cloudlena, evgenymarkov, michalkvasnicak, pret-a-porter, leoyli and 6 more
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4