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 it more strongly-typed when used with TypeScript #25

Merged
merged 4 commits into from
Apr 10, 2021

Conversation

fregante
Copy link
Owner

Closes #24

@fregante
Copy link
Owner Author

@stof can you try this change if you have time? If you pass a tag name in the selector, the tag type will also be inferred

delegate(document, 'textarea.comment', 'keydown', event => {});
// event will be of type `delegate.Event<HTMLTextAreaElement, KeyboardEvent>`

Use npm install delegate-it@next, it also includes your PR #19

index.ts Outdated
TEventType extends EventType = EventType
>(
base: EventTarget | Document | ArrayLike<Element> | string,
selector: string,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be selector: Selector ?

Copy link
Owner Author

@fregante fregante Mar 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for reviewing! That's right. I had forgotten to push this change, but it's already in 3.0.0-1

@stof
Copy link
Contributor

stof commented Apr 2, 2021

@fregante I confirm that the 3.0.0-1 version has much better type inference than the 2.0.2 version when running on JS code

@fregante fregante marked this pull request as ready for review April 2, 2021 08:07
@fregante fregante changed the title Add typed-query-selector Make it more strongly-typed when used with TypeScript Apr 10, 2021
@fregante fregante merged commit cceddeb into master Apr 10, 2021
@fregante fregante deleted the typed-selector branch April 10, 2021 11:03
@fregante fregante added the enhancement New feature or request label Apr 10, 2021
@fregante fregante mentioned this pull request Apr 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeScript: Use typed-query-selector to detect element type in delegateTarget
2 participants