Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React TypeScript type hint auto-completion does not work with React.forwardRef in Visual Studio Code

For normal React components, I can see the correct auto-completion for component's props like this:

enter image description here

But I try to create a component with React.forwardRef like below, it does not work, any idea?

export default React.forwardRef<unknown, BaseModalProps & FeedbackDetailsContentProps>((props: BaseModalProps & FeedbackDetailsContentProps, ref) => {
  return (
    <BaseModal {...props} onlyDisplayOkButton ref={ref} width={600}>
      <FeedbackDetailsContent {...props} />
    </BaseModal>
  );
});

enter image description here

like image 775
sunkehappy Avatar asked May 14 '26 17:05

sunkehappy


1 Answers

You should replace unknown with specified HTML Element type, eg. HTMLInputElement, and also type specified for props is unnecessary.

like image 114
hulufei Avatar answered May 17 '26 08:05

hulufei



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!