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

Missing TS typing for target property in CustomEvent-based component events #7868

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

Comments

@vursen
Copy link
Contributor

vursen commented Sep 26, 2024

Describe your motivation

Component events extending CustomEvent, such as DatePickerValidatedEvent, don't specify a TypeScript type for the target property:

export type DateTimePickerValidatedEvent = CustomEvent<{ valid: boolean }>;

The target property is only typed for ChangeEvent:

export type DateTimePickerChangeEvent = Event & {
target: DateTimePicker;
};

As a result, for custom events, the target has to be manually cast to the component type to access component properties in the listener:

Before After
image image

Describe the solution you'd like

Specify the component type as the type for the target property in all component events to save developers from tedious manual casting.

Describe alternatives you've considered

No response

Additional context

@web-padawan web-padawan added typescript TypeScript definitions issue DX Developer experience issue labels Sep 26, 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

2 participants