Skip to content

Commit

Permalink
Fix typescript error in example
Browse files Browse the repository at this point in the history
  • Loading branch information
ianobermiller committed Dec 27, 2018
1 parent 02aa1f4 commit 19f7d99
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 31 deletions.
8 changes: 7 additions & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,11 @@
"@types/react": "^16.7.13",
"@types/react-dom": "^16.0.11",
"typescript": "^3.2.2"
}
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
24 changes: 13 additions & 11 deletions example/src/Store.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved

import {Action, createStore} from 'redux';
import {Action, createStore, Store} from 'redux';
import reducer from './reducer';

export interface IState {
Expand All @@ -18,14 +18,16 @@ export type Action =
index: number;
};

export function makeStore() {
return createStore(reducer, {
lastUpdated: 0,
todos: [
'Make the fire!',
'Fix the breakfast!',
'Wash the dishes!',
'Do the mopping!',
],
});
export function makeStore(): Store<IState, Action> {
return createStore(reducer, INITIAL_STATE);
}

export const INITIAL_STATE: IState = {
lastUpdated: 0,
todos: [
'Make the fire!',
'Fix the breakfast!',
'Wash the dishes!',
'Do the mopping!',
],
};
1 change: 1 addition & 0 deletions example/src/react-app-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="react-scripts" />
4 changes: 2 additions & 2 deletions example/src/reducer.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved

import {Action, IState} from './Store';
import {Action, IState, INITIAL_STATE} from './Store';

export default function reducer(state: IState, action: Action) {
export default function reducer(state: IState = INITIAL_STATE, action: Action) {
switch (action.type) {
case 'add todo': {
return {
Expand Down
41 changes: 24 additions & 17 deletions example/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,38 @@
{
"compilerOptions": {
"baseUrl": ".",
"outDir": "build/dist",
"module": "esnext",
"target": "es5",
"lib": ["es6", "dom"],
"sourceMap": true,
"allowJs": true,
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"importHelpers": true,
"isolatedModules": true,
"jsx": "preserve",
"lib": ["es6", "dom"],
"module": "esnext",
"moduleResolution": "node",
"noEmit": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
"importHelpers": true,
"noUnusedLocals": true,
"outDir": "build/dist",
"resolveJsonModule": true,
"rootDir": "src",
"skipLibCheck": false,
"sourceMap": true,
"strict": true,
"strictNullChecks": true,
"suppressImplicitAnyIndexErrors": true,
"noUnusedLocals": true
"target": "es5"
},
"exclude": [
"build",
"scripts",
"acceptance-tests",
"webpack",
"build",
"jest",
"node_modules",
"scripts",
"src/setupTests.ts",
"node_modules"
]
"webpack"
],
"include": ["src"]
}

0 comments on commit 19f7d99

Please sign in to comment.