From f92fedd91973c26f0260dbb6faf98d2d3ed26c92 Mon Sep 17 00:00:00 2001 From: Rasmus Eneman Date: Tue, 17 Oct 2017 00:09:26 +0200 Subject: [PATCH] @types/react: Add documentation to confusing event properties (#20595) These properties can be non-obvious and some doc comments could be helpful --- types/react/index.d.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/types/react/index.d.ts b/types/react/index.d.ts index 864820aa63..29aef75598 100644 --- a/types/react/index.d.ts +++ b/types/react/index.d.ts @@ -430,6 +430,9 @@ declare namespace React { interface SyntheticEvent { bubbles: boolean; + /** + * A reference to the element on which the event listener is registered. + */ currentTarget: EventTarget & T; cancelable: boolean; defaultPrevented: boolean; @@ -442,6 +445,12 @@ declare namespace React { isPropagationStopped(): boolean; persist(): void; // If you thought this should be `EventTarget & T`, see https://github.com/DefinitelyTyped/DefinitelyTyped/pull/12239 + /** + * A reference to the element from which the event was originally dispatched. + * This might be a child element to the element on which the event listener is registered. + * + * @see currentTarget + */ target: EventTarget; timeStamp: number; type: string; @@ -483,7 +492,13 @@ declare namespace React { altKey: boolean; charCode: number; ctrlKey: boolean; + /** + * See [DOM Level 3 Events spec](https://www.w3.org/TR/uievents-key/#keys-modifier). for a list of valid (case-sensitive) arguments to this method. + */ getModifierState(key: string): boolean; + /** + * See the [DOM Level 3 Events spec](https://www.w3.org/TR/uievents-key/#named-key-attribute-values). for possible values + */ key: string; keyCode: number; locale: string; @@ -502,6 +517,9 @@ declare namespace React { clientX: number; clientY: number; ctrlKey: boolean; + /** + * See [DOM Level 3 Events spec](https://www.w3.org/TR/uievents-key/#keys-modifier). for a list of valid (case-sensitive) arguments to this method. + */ getModifierState(key: string): boolean; metaKey: boolean; nativeEvent: NativeMouseEvent; @@ -517,6 +535,9 @@ declare namespace React { altKey: boolean; changedTouches: TouchList; ctrlKey: boolean; + /** + * See [DOM Level 3 Events spec](https://www.w3.org/TR/uievents-key/#keys-modifier). for a list of valid (case-sensitive) arguments to this method. + */ getModifierState(key: string): boolean; metaKey: boolean; nativeEvent: NativeTouchEvent;