diff --git a/package.json b/package.json index c21a3c04..730f78de 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "@types/node": "^14.6.0", "@types/webpack": "^4.41.21", "@types/webpack-dev-server": "^3.11.0", + "@types/webpack-env": "^1.15.2", "@typescript-eslint/eslint-plugin": "^3.9.0", "@typescript-eslint/parser": "^3.9.0", "babel-eslint": "^10.1.0", diff --git a/packages/redux-devtools-slider-monitor/examples/todomvc/.babelrc b/packages/redux-devtools-slider-monitor/examples/todomvc/.babelrc index 3d0797a7..a01c7adc 100644 --- a/packages/redux-devtools-slider-monitor/examples/todomvc/.babelrc +++ b/packages/redux-devtools-slider-monitor/examples/todomvc/.babelrc @@ -1,5 +1,9 @@ { - "presets": ["@babel/preset-env", "@babel/preset-react"], + "presets": [ + "@babel/preset-env", + "@babel/preset-react", + "@babel/preset-typescript" + ], "plugins": [ "@babel/plugin-proposal-class-properties", "react-hot-loader/babel" diff --git a/packages/redux-devtools-slider-monitor/examples/todomvc/.eslintrc.js b/packages/redux-devtools-slider-monitor/examples/todomvc/.eslintrc.js new file mode 100644 index 00000000..70e1445e --- /dev/null +++ b/packages/redux-devtools-slider-monitor/examples/todomvc/.eslintrc.js @@ -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'], + }, + }, + ], +}; diff --git a/packages/redux-devtools-slider-monitor/examples/todomvc/actions/TodoActions.js b/packages/redux-devtools-slider-monitor/examples/todomvc/actions/TodoActions.js deleted file mode 100644 index f0122846..00000000 --- a/packages/redux-devtools-slider-monitor/examples/todomvc/actions/TodoActions.js +++ /dev/null @@ -1,42 +0,0 @@ -import * as types from '../constants/ActionTypes'; - -export function addTodo(text) { - return { - type: types.ADD_TODO, - text, - }; -} - -export function deleteTodo(id) { - return { - type: types.DELETE_TODO, - id, - }; -} - -export function editTodo(id, text) { - return { - type: types.EDIT_TODO, - id, - text, - }; -} - -export function markTodo(id) { - return { - type: types.MARK_TODO, - id, - }; -} - -export function markAll() { - return { - type: types.MARK_ALL, - }; -} - -export function clearMarked() { - return { - type: types.CLEAR_MARKED, - }; -} diff --git a/packages/redux-devtools-slider-monitor/examples/todomvc/actions/TodoActions.ts b/packages/redux-devtools-slider-monitor/examples/todomvc/actions/TodoActions.ts new file mode 100644 index 00000000..4169e9c1 --- /dev/null +++ b/packages/redux-devtools-slider-monitor/examples/todomvc/actions/TodoActions.ts @@ -0,0 +1,82 @@ +import * as types from '../constants/ActionTypes'; + +interface AddTodoAction { + type: typeof types.ADD_TODO; + text: string; +} +export function addTodo(text: string): AddTodoAction { + return { + type: types.ADD_TODO, + text, + }; +} + +interface DeleteTodoAction { + type: typeof types.DELETE_TODO; + id: number; +} +export function deleteTodo(id: number): DeleteTodoAction { + return { + type: types.DELETE_TODO, + id, + }; +} + +interface EditTodoAction { + type: typeof types.EDIT_TODO; + id: number; + text: string; +} +export function editTodo(id: number, text: string): EditTodoAction { + return { + type: types.EDIT_TODO, + id, + text, + }; +} + +interface MarkTodoAction { + type: typeof types.MARK_TODO; + id: number; +} +export function markTodo(id: number): MarkTodoAction { + return { + type: types.MARK_TODO, + id, + }; +} + +interface MarkAllAction { + type: typeof types.MARK_ALL; +} +export function markAll(): MarkAllAction { + return { + type: types.MARK_ALL, + }; +} + +interface ClearMarkedAction { + type: typeof types.CLEAR_MARKED; +} +export function clearMarked(): ClearMarkedAction { + return { + type: types.CLEAR_MARKED, + }; +} + +export type TodoAction = + | AddTodoAction + | DeleteTodoAction + | EditTodoAction + | MarkTodoAction + | MarkAllAction + | ClearMarkedAction; + +export interface TodoActions { + addTodo(text: string): AddTodoAction; + deleteTodo(id: number): DeleteTodoAction; + editTodo(id: number, text: string): EditTodoAction; + markTodo(id: number): MarkTodoAction; + markAll(): MarkAllAction; + clearMarked(): ClearMarkedAction; +} diff --git a/packages/redux-devtools-slider-monitor/examples/todomvc/components/Footer.js b/packages/redux-devtools-slider-monitor/examples/todomvc/components/Footer.tsx similarity index 74% rename from packages/redux-devtools-slider-monitor/examples/todomvc/components/Footer.js rename to packages/redux-devtools-slider-monitor/examples/todomvc/components/Footer.tsx index f583f39e..9462dd0c 100644 --- a/packages/redux-devtools-slider-monitor/examples/todomvc/components/Footer.js +++ b/packages/redux-devtools-slider-monitor/examples/todomvc/components/Footer.tsx @@ -1,7 +1,12 @@ -import React, { Component } from 'react'; +import React, { Component, MouseEventHandler } from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; -import { SHOW_ALL, SHOW_MARKED, SHOW_UNMARKED } from '../constants/TodoFilters'; +import { + SHOW_ALL, + SHOW_MARKED, + SHOW_UNMARKED, + TodoFilter, +} from '../constants/TodoFilters'; const FILTER_TITLES = { [SHOW_ALL]: 'All', @@ -9,7 +14,15 @@ const FILTER_TITLES = { [SHOW_MARKED]: 'Completed', }; -export default class Footer extends Component { +interface Props { + markedCount: number; + unmarkedCount: number; + filter: TodoFilter; + onClearMarked: MouseEventHandler; + onShow: (filter: TodoFilter) => void; +} + +export default class Footer extends Component { static propTypes = { markedCount: PropTypes.number.isRequired, unmarkedCount: PropTypes.number.isRequired, @@ -23,7 +36,7 @@ export default class Footer extends Component {