Update templates to support TypeScript 'strict' mode

This commit is contained in:
Stephan Troyer
2017-07-13 00:08:42 +02:00
committed by Steve Sanderson
parent 8b37dc8561
commit b8c006a3e9
27 changed files with 77 additions and 58 deletions

View File

@@ -7,7 +7,7 @@ import { AppThunkAction } from './';
export interface WeatherForecastsState {
isLoading: boolean;
startDateIndex: number;
startDateIndex?: number;
forecasts: WeatherForecast[];
}
@@ -23,14 +23,14 @@ export interface WeatherForecast {
// They do not themselves have any side-effects; they just describe something that is going to happen.
interface RequestWeatherForecastsAction {
type: 'REQUEST_WEATHER_FORECASTS',
type: 'REQUEST_WEATHER_FORECASTS';
startDateIndex: number;
}
interface ReceiveWeatherForecastsAction {
type: 'RECEIVE_WEATHER_FORECASTS',
type: 'RECEIVE_WEATHER_FORECASTS';
startDateIndex: number;
forecasts: WeatherForecast[]
forecasts: WeatherForecast[];
}
// Declare a 'discriminated union' type. This guarantees that all references to 'type' properties contain one of the
@@ -60,7 +60,7 @@ export const actionCreators = {
// ----------------
// REDUCER - For a given state and action, returns the new state. To support time travel, this must not mutate the old state.
const unloadedState: WeatherForecastsState = { startDateIndex: null, forecasts: [], isLoading: false };
const unloadedState: WeatherForecastsState = { startDateIndex: undefined, forecasts: [], isLoading: false };
export const reducer: Reducer<WeatherForecastsState> = (state: WeatherForecastsState, incomingAction: Action) => {
const action = incomingAction as KnownAction;