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

Bug: Add types to public events EventEmitter #2854

Closed
am-maneaters opened this issue Aug 18, 2021 · 4 comments
Closed

Bug: Add types to public events EventEmitter #2854

am-maneaters opened this issue Aug 18, 2021 · 4 comments
Assignees
Labels
4 - verified Issues that have been released and confirmed resolved. bug Bug reports for broken functionality. Issues should include a reproduction of the bug. has workaround Issues have a workaround available in the meantime.

Comments

@am-maneaters
Copy link

am-maneaters commented Aug 18, 2021

Many components are either missing or have incomplete event types which makes causes a headache with handling events in typescript.

For example, here is an excerpt from my code using the calcite-components-react package

onCalciteInputInput={(evt) => {
    // evt currently typed as CustomEvent<any>
    const typedEvent = evt as CustomEvent<{ value: string }>;
    const newValue = typedEvent.detail.value;
}}

You can see the return type on calciteInputInput is currently any, when it should have a specific type.

This is because the EventEmitter has no type provided, so it auto-casts to any

Actual Behavior

Current calciteInputInput definition:

 @Event({ cancelable: true }) calciteInputInput: EventEmitter;

Expected Behavior

Proposed definition:

  @Event({ cancelable: true }) calciteInputInput: EventEmitter<{
    element: HTMLInputElement | HTMLTextAreaElement;
    value: string;
    nativeEvent: any;
  }>;

I'd like to take this task on if it's something others think would be worth doing

@am-maneaters am-maneaters added 0 - new New issues that need assignment. bug Bug reports for broken functionality. Issues should include a reproduction of the bug. needs triage Planning workflow - pending design/dev review. labels Aug 18, 2021
@jcfranco
Copy link
Member

Thanks for bringing this up. We need to do an audit of our custom events as we will be removing any custom event payload that is not already on the component itself.

For the calciteInputInput case, you can to through the event's target/currentTarget to get the value: https://codepen.io/jcfranco/pen/eYRmJej?editors=0010

cc @benelan

@jcfranco jcfranco removed the needs triage Planning workflow - pending design/dev review. label Aug 25, 2021
@jcfranco jcfranco added this to the Freezer milestone Aug 25, 2021
@jcfranco jcfranco added the has workaround Issues have a workaround available in the meantime. label Mar 15, 2022
@jcfranco jcfranco modified the milestones: Freezer, Sprint 05/23 - 06/03 Jun 1, 2022
@jcfranco jcfranco self-assigned this Jun 1, 2022
@jcfranco jcfranco added 1 - assigned Issues that are assigned to a sprint and a team member. and removed 0 - new New issues that need assignment. labels Jun 1, 2022
@jcfranco jcfranco added 2 - in development Issues that are actively being worked on. and removed 1 - assigned Issues that are assigned to a sprint and a team member. labels Jul 27, 2022
@driskull
Copy link
Member

It seems all events have types now. @geospatialem can you confirm?

@driskull driskull added 3 - installed Issues that have been merged to master branch and are ready for final confirmation. and removed 0 - new New issues that need assignment. labels Dec 13, 2022
@github-actions
Copy link
Contributor

Installed and assigned for verification.

@geospatialem geospatialem added 4 - verified Issues that have been released and confirmed resolved. and removed 3 - installed Issues that have been merged to master branch and are ready for final confirmation. labels Dec 14, 2022
@geospatialem
Copy link
Member

Verified on the master branch. 👍🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4 - verified Issues that have been released and confirmed resolved. bug Bug reports for broken functionality. Issues should include a reproduction of the bug. has workaround Issues have a workaround available in the meantime.
Projects
None yet
Development

No branches or pull requests

5 participants