From d6de865236267347fa6f527c84fd478b65524b99 Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Wed, 29 Jul 2015 09:53:13 -0700 Subject: [PATCH] Cleanup AppRegistry types Summary: Found some missing/wrong types when playing around with the AppRegistry for routing work in the main app. --- Libraries/AppRegistry/AppRegistry.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Libraries/AppRegistry/AppRegistry.js b/Libraries/AppRegistry/AppRegistry.js index 7465d85b9..44cc1c72e 100644 --- a/Libraries/AppRegistry/AppRegistry.js +++ b/Libraries/AppRegistry/AppRegistry.js @@ -22,9 +22,11 @@ if (__DEV__) { var runnables = {}; +type ComponentProvider = () => ReactClass; + type AppConfig = { appKey: string; - component: ReactClass; + component?: ComponentProvider; run?: Function; }; @@ -46,12 +48,13 @@ var AppRegistry = { if (appConfig.run) { AppRegistry.registerRunnable(appConfig.appKey, appConfig.run); } else { + invariant(appConfig.component, 'No component provider passed in'); AppRegistry.registerComponent(appConfig.appKey, appConfig.component); } } }, - registerComponent: function(appKey: string, getComponentFunc: Function): string { + registerComponent: function(appKey: string, getComponentFunc: ComponentProvider): string { runnables[appKey] = { run: (appParameters) => renderApplication(getComponentFunc(), appParameters.initialProps, appParameters.rootTag)