-
-
Notifications
You must be signed in to change notification settings - Fork 634
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
Add enhanced typings #1287
Merged
Merged
Add enhanced typings #1287
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
124d1cd
Add enhanced typings
as-com bd4a357
Cleanup
as-com 7586b89
Import JSX, whoops
as-com 095cfd2
Refactor Events definition; add support for linkEvent
as-com 8145795
Remove fixed TODO
as-com c763170
Lots of cleanup, also address #1295
as-com 2120a8b
Clean up WrapperComponent
as-com 0bba495
Remove global.d.ts
as-com File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// | ||
// Event System | ||
// ---------------------------------------------------------------------- | ||
|
||
import { | ||
NativeAnimationEvent, NativeClipboardEvent, NativeCompositionEvent, NativeDragEvent, NativeFocusEvent, | ||
NativeKeyboardEvent, | ||
NativeMouseEvent, NativeTouchEvent, NativeTransitionEvent, NativeUIEvent, NativeWheelEvent | ||
} from "../../JSX"; | ||
import { LinkedEvent } from "./linkEvent"; | ||
|
||
export interface SemiSyntheticEvent<T> extends Event { | ||
/** | ||
* A reference to the element on which the event listener is registered. | ||
*/ | ||
currentTarget: EventTarget & T; | ||
} | ||
|
||
export type ClipboardEvent<T> = SemiSyntheticEvent<T> & NativeClipboardEvent; | ||
export type CompositionEvent<T> = SemiSyntheticEvent<T> & NativeCompositionEvent; | ||
export type DragEvent<T> = MouseEvent<T> & NativeDragEvent; | ||
export type FocusEvent<T> = SemiSyntheticEvent<T> & NativeFocusEvent; | ||
export type FormEvent<T> = SemiSyntheticEvent<T>; | ||
|
||
export interface InvalidEvent<T> extends SemiSyntheticEvent<T> { | ||
target: EventTarget & T; | ||
} | ||
|
||
export interface ChangeEvent<T> extends SemiSyntheticEvent<T> { | ||
target: EventTarget & T; | ||
} | ||
|
||
export type KeyboardEvent<T> = SemiSyntheticEvent<T> & NativeKeyboardEvent; | ||
export type MouseEvent<T> = SemiSyntheticEvent<T> & NativeMouseEvent; | ||
export type TouchEvent<T> = SemiSyntheticEvent<T> & NativeTouchEvent; | ||
export type UIEvent<T> = SemiSyntheticEvent<T> & NativeUIEvent; | ||
export type WheelEvent<T> = MouseEvent<T> & NativeWheelEvent; | ||
export type AnimationEvent<T> = SemiSyntheticEvent<T> & NativeAnimationEvent; | ||
export type TransitionEvent<T> = SemiSyntheticEvent<T> & NativeTransitionEvent; | ||
|
||
// | ||
// Event Handler Types | ||
// ---------------------------------------------------------------------- | ||
|
||
export type EventHandler<E extends SemiSyntheticEvent<any>> = { bivarianceHack(event: E): void }["bivarianceHack"] | LinkedEvent<any, E>; | ||
|
||
export type InfernoEventHandler<T> = EventHandler<SemiSyntheticEvent<T>>; | ||
|
||
export type ClipboardEventHandler<T> = EventHandler<ClipboardEvent<T>>; | ||
export type CompositionEventHandler<T> = EventHandler<CompositionEvent<T>>; | ||
export type DragEventHandler<T> = EventHandler<DragEvent<T>>; | ||
export type FocusEventHandler<T> = EventHandler<FocusEvent<T>>; | ||
export type FormEventHandler<T> = EventHandler<FormEvent<T>>; | ||
export type ChangeEventHandler<T> = EventHandler<ChangeEvent<T>>; | ||
export type KeyboardEventHandler<T> = EventHandler<KeyboardEvent<T>>; | ||
export type MouseEventHandler<T> = EventHandler<MouseEvent<T>>; | ||
export type TouchEventHandler<T> = EventHandler<TouchEvent<T>>; | ||
export type UIEventHandler<T> = EventHandler<UIEvent<T>>; | ||
export type WheelEventHandler<T> = EventHandler<WheelEvent<T>>; | ||
export type AnimationEventHandler<T> = EventHandler<AnimationEvent<T>>; | ||
export type TransitionEventHandler<T> = EventHandler<TransitionEvent<T>>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typing seems to be more correct with
any[]
as before?