11import React from 'react' ;
22
3- import { createBrowserHistory as createHistory } from 'history' ;
4- import { createRouter } from './uss-router' ;
3+ import { createBrowserHistory as createHistory , Path , Location } from 'history' ;
4+ import { createRouter , PlainOrThunk } from './uss-router' ;
55import UssRouter from './uss-router/Router' ;
66
77import qs from 'qs' ;
88import Route from 'route-parser' ;
99
1010import * as actions from './actions' ;
11+ import State from './state' ;
12+ import { Channel , Edition , Mode , Page } from './types' ;
1113
1214const homeRoute = new Route ( '/' ) ;
1315const helpRoute = new Route ( '/help' ) ;
1416
15- const stateSelector = ( { page, configuration : { channel, mode, edition } } ) => ( {
17+ interface Substate {
18+ page : Page ;
19+ configuration : {
20+ channel : Channel ;
21+ mode : Mode ;
22+ edition : Edition ;
23+ }
24+ }
25+
26+ const stateSelector = ( { page, configuration : { channel, mode, edition } } : State ) : Substate => ( {
1627 page,
1728 configuration : {
1829 channel,
@@ -21,7 +32,7 @@ const stateSelector = ({ page, configuration: { channel, mode, edition } }) => (
2132 } ,
2233} ) ;
2334
24- const stateToLocation = ( { page, configuration } ) => {
35+ const stateToLocation = ( { page, configuration } : Substate ) : Partial < Path > => {
2536 switch ( page ) {
2637 case 'help' : {
2738 return {
@@ -42,7 +53,7 @@ const stateToLocation = ({ page, configuration }) => {
4253 }
4354} ;
4455
45- const locationToAction = location => {
56+ const locationToAction = ( location : Location ) : PlainOrThunk < State , actions . Action > | null => {
4657 const matchedHelp = helpRoute . match ( location . pathname ) ;
4758
4859 if ( matchedHelp ) {
@@ -61,7 +72,7 @@ const locationToAction = location => {
6172export default class Router extends React . Component < RouterProps > {
6273 private router : any ;
6374
64- public constructor ( props ) {
75+ public constructor ( props : RouterProps ) {
6576 super ( props ) ;
6677
6778 const history = createHistory ( ) ;
0 commit comments