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

Make inputElement type more specific to eliminate unnecessary casting #7879

Open
vursen opened this issue Sep 27, 2024 · 0 comments
Open

Make inputElement type more specific to eliminate unnecessary casting #7879

vursen opened this issue Sep 27, 2024 · 0 comments
Labels
DX Developer experience issue typescript TypeScript definitions issue

Comments

@vursen
Copy link
Contributor

vursen commented Sep 27, 2024

Describe your motivation

The inputElement property is currently defined as HTMLElement, which is a type that represents any HTML element. However, in most of the components, this property is expected to reference an <input> or <textarea> exclusively. As a result, developers are required to cast this property to the more specific HTMLInputElement or HTMLTextAreaElement whenever they want to get access to input-specific properties like value, for example to check if the field has bad input.

image

Describe the solution you'd like

The inputElement property could have a more specific type based on the component:

  • HTMLInputElement for components like text-field, date-picker, etc
  • HTMLTextAreaElement for components like text-area
  • HTMLElement (current type) for components like date-picker-light, etc

Describe alternatives you've considered

No response

Additional context

No response

@vursen vursen changed the title Make inputElement property type more specific to eliminate unnecessary casting Make inputElement type more specific to eliminate unnecessary casting Sep 27, 2024
@web-padawan web-padawan added the typescript TypeScript definitions issue label Sep 27, 2024
@yuriy-fix yuriy-fix added the DX Developer experience issue label Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DX Developer experience issue typescript TypeScript definitions issue
Projects
None yet
Development

No branches or pull requests

3 participants