Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: specify explicit return type for components with forwardRef #291

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

web-padawan
Copy link
Member

Description

Fixes #290

This fixes the error with IntelliJ showing ForwardRefExoticComponent<unknown> for components like Select:

Screenshot 2025-01-14 at 15 00 58

Here's the overview of the .d.ts output change:

Before

declare const ForwardedSelect: import("react").ForwardRefExoticComponent<Partial<Omit<Partial<import("./utils/createComponent.js").ThemedWebComponentProps<SelectElement, Readonly<{
    onValidated: import("@lit/react").EventName<import("@vaadin/select").SelectEventMap["validated"]>;
    onChange: import("@lit/react").EventName<import("@vaadin/select").SelectEventMap["change"]>;
    onInvalidChanged: import("@lit/react").EventName<import("@vaadin/select").SelectEventMap["invalid-changed"]>;
    onOpenedChanged: import("@lit/react").EventName<import("@vaadin/select").SelectEventMap["opened-changed"]>;
    onValueChanged: import("@lit/react").EventName<import("@vaadin/select").SelectEventMap["value-changed"]>;
}>>>, "children" | "renderer">> & Readonly<{
    children?: ReactNode | SelectRenderer | Array<ReactNode | SelectRenderer>;
    renderer?: SelectRenderer | null;
}> & import("react").RefAttributes<SelectElement>>;

After

declare const ForwardedSelect: ForwardRefExoticComponent<SelectProps & RefAttributes<SelectElement>>;

Type of change

  • Bugfix

Note

When testing the change in react-components project itself, make sure you use import from the npm package:

import { Select } from '@vaadin/react-components';

Otherwise, when using relative imports, the TS compiler produces correct types with the old version too.

import { Select } from '../../packages/react-components/src/Select.js';

@sissbruecker
Copy link
Contributor

I also couldn't reproduce this in my version of IntelliJ (2024.2.5). Tested both in react-components and in a new Hilla project. I noticed that it took a few seconds for the types to be available after importing the component though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot use IntelliSense for Select component
2 participants