-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(redux-devtools): convert counter example to TypeScript (#616)
* stash * finish * optional
- Loading branch information
1 parent
2faa163
commit f1e3f4f
Showing
32 changed files
with
321 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module.exports = { | ||
extends: '../../../../.eslintrc', | ||
overrides: [ | ||
{ | ||
files: ['*.ts', '*.tsx'], | ||
extends: '../../../../eslintrc.ts.react.base.json', | ||
parserOptions: { | ||
tsconfigRootDir: __dirname, | ||
project: ['./tsconfig.json'], | ||
}, | ||
}, | ||
{ | ||
files: ['webpack.config.ts'], | ||
extends: '../../../../eslintrc.ts.base.json', | ||
parserOptions: { | ||
tsconfigRootDir: __dirname, | ||
project: ['./tsconfig.webpack.json'], | ||
}, | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 0 additions & 33 deletions
33
packages/redux-devtools/examples/counter/src/actions/CounterActions.js
This file was deleted.
Oops, something went wrong.
53 changes: 53 additions & 0 deletions
53
packages/redux-devtools/examples/counter/src/actions/CounterActions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { ThunkAction } from 'redux-thunk'; | ||
import { INCREMENT_COUNTER, DECREMENT_COUNTER } from '../constants/ActionTypes'; | ||
import { CounterState } from '../reducers'; | ||
|
||
interface IncrementCounterAction { | ||
type: typeof INCREMENT_COUNTER; | ||
} | ||
export function increment(): IncrementCounterAction { | ||
return { | ||
type: INCREMENT_COUNTER, | ||
}; | ||
} | ||
|
||
interface DecrementCounterAction { | ||
type: typeof DECREMENT_COUNTER; | ||
} | ||
export function decrement(): DecrementCounterAction { | ||
return { | ||
type: DECREMENT_COUNTER, | ||
}; | ||
} | ||
|
||
export type CounterAction = IncrementCounterAction | DecrementCounterAction; | ||
|
||
export function incrementIfOdd(): ThunkAction< | ||
void, | ||
CounterState, | ||
never, | ||
CounterAction | ||
> { | ||
return (dispatch, getState) => { | ||
const { counter } = getState(); | ||
|
||
if (counter % 2 === 0) { | ||
return; | ||
} | ||
|
||
dispatch(increment()); | ||
}; | ||
} | ||
|
||
export function incrementAsync(): ThunkAction< | ||
void, | ||
CounterState, | ||
never, | ||
CounterAction | ||
> { | ||
return (dispatch) => { | ||
setTimeout(() => { | ||
dispatch(increment()); | ||
}, 1000); | ||
}; | ||
} |
9 changes: 8 additions & 1 deletion
9
...xamples/counter/src/components/Counter.js → ...amples/counter/src/components/Counter.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.