33 *
44 * This source code is licensed under the MIT license found in the
55 * LICENSE file in the root directory of this source tree.
6+ *
7+ * @flow
68 */
79
810/* eslint valid-typeof: 0 */
911
1012import getEventCharCode from './getEventCharCode' ;
1113
14+ type EventInterfaceType = {
15+ [ propName : string ] : 0 | ( ( event : { [ propName : string ] : mixed } ) => mixed ) ,
16+ } ;
17+
1218/**
1319 * @interface Event
1420 * @see http://www.w3.org/TR/DOM-Level-3-Events/
1521 */
16- const EventInterface = {
22+ const EventInterface : EventInterfaceType = {
1723 eventPhase : 0 ,
1824 bubbles : 0 ,
1925 cancelable : 0 ,
@@ -46,12 +52,12 @@ function functionThatReturnsFalse() {
4652 * DOM interface; custom application-specific events can also subclass this.
4753 */
4854export function SyntheticEvent (
49- reactName ,
50- reactEventType ,
51- targetInst ,
52- nativeEvent ,
53- nativeEventTarget ,
54- Interface = EventInterface ,
55+ reactName : string | null ,
56+ reactEventType : string ,
57+ targetInst : Fiber ,
58+ nativeEvent : { [ propName : string ] : mixed } ,
59+ nativeEventTarget : null | EventTarget ,
60+ Interface : EventInterfaceType = EventInterface ,
5561) {
5662 this. _reactName = reactName ;
5763 this . _targetInst = targetInst ;
@@ -95,6 +101,7 @@ Object.assign(SyntheticEvent.prototype, {
95101
96102 if ( event . preventDefault ) {
97103 event . preventDefault ( ) ;
104+ // $FlowFixMe - flow is not aware of `unknown` in IE
98105 } else if ( typeof event . returnValue !== 'unknown' ) {
99106 event . returnValue = false ;
100107 }
@@ -109,6 +116,7 @@ Object.assign(SyntheticEvent.prototype, {
109116
110117 if ( event . stopPropagation ) {
111118 event . stopPropagation ( ) ;
119+ // $FlowFixMe - flow is not aware of `unknown` in IE
112120 } else if ( typeof event . cancelBubble !== 'unknown' ) {
113121 // The ChangeEventPlugin registers a "propertychange" event for
114122 // IE. This event does not support bubbling or cancelling, and
@@ -138,7 +146,7 @@ Object.assign(SyntheticEvent.prototype, {
138146 isPersistent : functionThatReturnsTrue ,
139147} ) ;
140148
141- export const UIEventInterface = {
149+ export const UIEventInterface : EventInterfaceType = {
142150 ...EventInterface ,
143151 view : 0 ,
144152 detail : 0 ,
@@ -154,7 +162,7 @@ let isMovementYSet = false;
154162 * @interface MouseEvent
155163 * @see http://www.w3.org/TR/DOM-Level-3-Events/
156164 */
157- export const MouseEventInterface = {
165+ export const MouseEventInterface : EventInterfaceType = {
158166 ...UIEventInterface ,
159167 screenX : 0 ,
160168 screenY : 0 ,
@@ -213,7 +221,7 @@ export const MouseEventInterface = {
213221 * @interface DragEvent
214222 * @see http://www.w3.org/TR/DOM-Level-3-Events/
215223 */
216- export const DragEventInterface = {
224+ export const DragEventInterface : EventInterfaceType = {
217225 ...MouseEventInterface ,
218226 dataTransfer : 0 ,
219227} ;
@@ -222,7 +230,7 @@ export const DragEventInterface = {
222230 * @interface FocusEvent
223231 * @see http://www.w3.org/TR/DOM-Level-3-Events/
224232 */
225- export const FocusEventInterface = {
233+ export const FocusEventInterface : EventInterfaceType = {
226234 ...UIEventInterface ,
227235 relatedTarget : 0 ,
228236} ;
@@ -232,7 +240,7 @@ export const FocusEventInterface = {
232240 * @see http://www.w3.org/TR/css3-animations/#AnimationEvent-interface
233241 * @see https://developer.mozilla.org/en-US/docs/Web/API/AnimationEvent
234242 */
235- export const AnimationEventInterface = {
243+ export const AnimationEventInterface : EventInterfaceType = {
236244 ...EventInterface ,
237245 animationName : 0 ,
238246 elapsedTime : 0 ,
@@ -243,7 +251,7 @@ export const AnimationEventInterface = {
243251 * @interface Event
244252 * @see http://www.w3.org/TR/clipboard-apis/
245253 */
246- export const ClipboardEventInterface = {
254+ export const ClipboardEventInterface : EventInterfaceType = {
247255 ...EventInterface ,
248256 clipboardData : function ( event ) {
249257 return 'clipboardData' in event
@@ -256,7 +264,7 @@ export const ClipboardEventInterface = {
256264 * @interface Event
257265 * @see http://www.w3.org/TR/DOM-Level-3-Events/#events-compositionevents
258266 */
259- export const CompositionEventInterface = {
267+ export const CompositionEventInterface : EventInterfaceType = {
260268 ...EventInterface ,
261269 data : 0 ,
262270} ;
@@ -267,7 +275,7 @@ export const CompositionEventInterface = {
267275 * /#events-inputevents
268276 */
269277// Happens to share the same list for now.
270- export const InputEventInterface = CompositionEventInterface ;
278+ export const InputEventInterface : EventInterfaceType = CompositionEventInterface ;
271279
272280/**
273281 * Normalization of deprecated HTML5 `key` values
0 commit comments