From cbad15863d0cf74ed9329ef0282c072962aa4c37 Mon Sep 17 00:00:00 2001 From: Eli White Date: Wed, 22 Aug 2018 12:49:15 -0700 Subject: [PATCH] Adding a more complete type for ReactNativeBaseComponentViewConfig Summary: As we add js view configs to our view managers, we want this type to be a little bit more strict. This will be especially useful as we start removing certain keys (like NativeProps) which aren't actually necessary, this will make sure we remove them everywhere. Reviewed By: yungsters Differential Revision: D9416905 fbshipit-source-id: 6b12e38b9d56969a81ec5d4f2920298e4919f7be --- Libraries/Renderer/shims/ReactNativeTypes.js | 41 +++++++++++++++++--- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/Libraries/Renderer/shims/ReactNativeTypes.js b/Libraries/Renderer/shims/ReactNativeTypes.js index 991aa338e77..2dce8ce507f 100644 --- a/Libraries/Renderer/shims/ReactNativeTypes.js +++ b/Libraries/Renderer/shims/ReactNativeTypes.js @@ -44,13 +44,42 @@ type DirectEventType = { registrationName: string, }; -export type ReactNativeBaseComponentViewConfig = { - validAttributes: Object, +type AttributeType = + | true + | $ReadOnly<{| + diff: ?(arg1: T, arg2: T) => boolean, + process: ?(arg1: any) => any, + |}>; + +export type ReactNativeBaseComponentViewConfig = $ReadOnly<{| + baseModuleName?: string, + bubblingEventTypes?: $ReadOnly<{ + [eventName: string]: $ReadOnly<{| + phasedRegistrationNames: $ReadOnly<{| + captured: string, + bubbled: string, + |}>, + |}>, + }>, + Commands?: $ReadOnly<{ + [commandName: string]: number, + }>, + directEventTypes?: $ReadOnly<{ + [eventName: string]: $ReadOnly<{| + registrationName: string, + |}>, + }>, + NativeProps?: $ReadOnly<{ + [propName: string]: string, + }>, uiViewClassName: string, - bubblingEventTypes?: {[topLevelType: string]: BubblingEventType}, - directEventTypes?: {[topLevelType: string]: DirectEventType}, - propTypes?: Object, -}; + validAttributes: $ReadOnly<{ + [propName: string]: AttributeType, + style: $ReadOnly<{ + [propName: string]: AttributeType, + }>, + }>, +|}>; export type ViewConfigGetter = () => ReactNativeBaseComponentViewConfig;