Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

fix(typings): synthetic event #740

Merged
merged 3 commits into from
Jan 17, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion types/utils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ export type ReactChildren = React.ReactNodeArray | React.ReactNode
export type ReactPropsStrict<T> = { [K in keyof T]: NullableIfUndefined<T[K]> }
export type ReactProps<T> = Extendable<ReactPropsStrict<T>>

export type ComponentEventHandler<TProps> = (event: React.SyntheticEvent, data: TProps) => void
export type ComponentEventHandler<TProps> = (
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
export type ComponentEventHandler<TProps> = (
export type ComponentEventHandler<TProps, TElem = HTMLElement> = (

Can we make this a generic?

Copy link
Contributor Author

@kuzhelov kuzhelov Jan 17, 2019

Choose a reason for hiding this comment

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

yes, although not sure whether it is necessary to introduce this variability now, as it is pretty much clear that it will always be about HTMLElement for this handler's type - thus, not sure if we should make this type to be customizable (as it will, probably, will be an indication of some improper assumptions)

event: React.SyntheticEvent<HTMLElement>,
data: TProps,
) => void

type ChildrenProps = { children: any }
export type PropsOf<T> = T extends React.ComponentClass<Extendable<infer TProps>>
Expand Down