I have a React component written as a function this way:
function Button({ text, icon }) {
return ...
}
Button.propTypes = {
text: PropTypes.string.isRequired,
icon: PropTypes.string.isRequired
}
when using this component, I get the autocompletion / intellisense in vscode
If i wrap this component in React.forwardRef,
export default React.forwardRef((props, ref) => <Button btnRef={ref} {...props} />)
then I get the intellisense for the forwardRef function, which does not help my usage, because now there is no way for me to get the props autocompleted / show up in intellisense.
I have tried annotating the React.forwardRef with jsdoc extends / augments but to no success, in that case even the default intellisense for forwardRef usage stops showing up. (I believe this is because vscode gives more preference to available types than jsdoc comments). Is there a way for me to get the intellisense for the wrapped component working similar to the unwrapped component? This would be inline with the understanding that I have for using the wrapped component in a similar way as the unwrapped component.