A Type-safe TODO list application written in TypeScript following by the wonderful lessons of egghead.io.
This repository is TypeScript version of the lessons bellow.
https://egghead.io/courses/getting-started-with-redux
https://nwtgck.github.io/egghead-todo-typescript-react/build/
$ cd <this-repo>
$ npm install
$ npm start
Then, go to http://localhost:8080.
$ cd <this-repo>
$ npm install
$ npm run build
Then, you can open ./build/index.html
by your browser.
- TypeScript
- React
- Redux
- webpack
Filter
, for example, is seems to be just string.
But only 'SHOW_ALL'
, 'SHOW_ACTIVE'
and 'SHOW_COMPLETED''
are acceptable as Filter
because Filter
type is defined bellow.
type Filter = 'SHOW_ALL' | 'SHOW_ACTIVE' | 'SHOW_COMPLETED';
Because of this feature, we can use string more relax without considering typo.
.tsx bellow is valid.
<FilterLink filter={'SHOW_ALL'}>All</FilterLink>
But, the mistake bellow will be detected at compile time. Good!
<FilterLink filter={'SHO_ALL'}>All</FilterLink>
This is only just one example. Almost things are typed, and some human errors can be detected at compile time.