44 * @license MIT
55 */
66
7+ import { Store } from 'common/redux' ;
8+ import { Window } from './layouts' ;
79import { selectBackend } from './backend' ;
810import { selectDebug } from './debug/selectors' ;
9- import { Window } from './layouts' ;
1011
1112const requireInterface = require . context ( './interfaces' ) ;
1213
13- const routingError = ( type , name ) => ( ) => {
14- return (
15- < Window >
16- < Window . Content scrollable >
17- { type === 'notFound' && (
18- < div > Interface < b > { name } </ b > was not found.</ div >
19- ) }
20- { type === 'missingExport' && (
21- < div > Interface < b > { name } </ b > is missing an export.</ div >
22- ) }
23- </ Window . Content >
24- </ Window >
25- ) ;
26- } ;
14+ const routingError =
15+ ( type : 'notFound' | 'missingExport' , name : string ) => ( ) => {
16+ return (
17+ < Window >
18+ < Window . Content scrollable >
19+ { type === 'notFound' && (
20+ < div >
21+ Interface < b > { name } </ b > was not found.
22+ </ div >
23+ ) }
24+ { type === 'missingExport' && (
25+ < div >
26+ Interface < b > { name } </ b > is missing an export.
27+ </ div >
28+ ) }
29+ </ Window . Content >
30+ </ Window >
31+ ) ;
32+ } ;
2733
34+ // Displays an empty Window with scrollable content
2835const SuspendedWindow = ( ) => {
2936 return (
3037 < Window >
@@ -33,7 +40,8 @@ const SuspendedWindow = () => {
3340 ) ;
3441} ;
3542
36- export const getRoutedComponent = store => {
43+ // Get the component for the current route
44+ export const getRoutedComponent = ( store : Store ) => {
3745 const state = store . getState ( ) ;
3846 const { suspended, config } = selectBackend ( state ) ;
3947 if ( suspended ) {
@@ -48,19 +56,20 @@ export const getRoutedComponent = store => {
4856 }
4957 const name = config ?. interface ;
5058 const interfacePathBuilders = [
51- name => `./${ name } .tsx` ,
52- name => `./${ name } .js` ,
53- name => `./${ name } /index.tsx` ,
54- name => `./${ name } /index.js` ,
59+ ( name : string ) => `./${ name } .tsx` ,
60+ ( name : string ) => `./${ name } .jsx` ,
61+ ( name : string ) => `./${ name } .js` ,
62+ ( name : string ) => `./${ name } /index.tsx` ,
63+ ( name : string ) => `./${ name } /index.jsx` ,
64+ ( name : string ) => `./${ name } /index.js` ,
5565 ] ;
5666 let esModule ;
5767 while ( ! esModule && interfacePathBuilders . length > 0 ) {
58- const interfacePathBuilder = interfacePathBuilders . shift ( ) ;
68+ const interfacePathBuilder = interfacePathBuilders . shift ( ) ! ;
5969 const interfacePath = interfacePathBuilder ( name ) ;
6070 try {
6171 esModule = requireInterface ( interfacePath ) ;
62- }
63- catch ( err ) {
72+ } catch ( err ) {
6473 if ( err . code !== 'MODULE_NOT_FOUND' ) {
6574 throw err ;
6675 }
0 commit comments