import { Layout , LayoutRoot , Navigation , Options } from 'react-native-navigation' ; import createLayout from './createLayout' ; export interface SetRootCommand { ( layoutRoot ) : Promise < any > ; ( layout ) : Promise < any > ; < P = { } > ( name , passProps ? , options ? ) : Promise < any > ; } function setRoot < P = { } > ( nameOrLayout , passProps ? , options ? ) { let layoutRoot ; if ( typeof nameOrLayout === 'string' ) { layoutRoot = { root : createLayout < P > ( nameOrLayout , passProps , options ) } as LayoutRoot ; } else if ( ( nameOrLayout as LayoutRoot ) . root ) { layoutRoot = nameOrLayout as LayoutRoot ; } else { layoutRoot = { root : nameOrLayout } as LayoutRoot ; } return Navigation . setRoot ( layoutRoot ) ; } export default setRoot ;