How to use typescript jsdoc annotations for React PropTypes

后端 未结 3 726
悲&欢浪女
悲&欢浪女 2021-02-07 14:22

When defining react components using typescript we can write something like:

class SomeComponent extends React.Component {
         


        
3条回答
  •  遥遥无期
    2021-02-07 15:20

    I prefer following form (es2015 + @types/react):

    /**
     * @typedef {object} Props
     * @prop {string} className
     * @prop {number} numberProp
     *
     * @extends {Component}
     */
    export default class SomeComponent extends Component {
        render() {
            return (
                
    {this.props.numberProp}
    ); } }

提交回复
热议问题