Skip to content

Enhance use-outside-click.ts Hook with Strict Typing for Events and Callback. - #2

Open
vignesh1507 wants to merge 1 commit into
bennettai:mainfrom
vignesh1507:patch-1
Open

Enhance use-outside-click.ts Hook with Strict Typing for Events and Callback.#2
vignesh1507 wants to merge 1 commit into
bennettai:mainfrom
vignesh1507:patch-1

Conversation

@vignesh1507

Copy link
Copy Markdown

Changes that i have made to the code are as follows:

  1. Typed callback and event: I replaced the any type with MouseEvent | TouchEvent for the event and provided a more specific type for the callback function.

  2. event.target as Node: Since event.target is of type EventTarget, which may not directly contain DOM manipulation methods, casting it to Node ensures the contains() method is correctly interpreted by TypeScript.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant