This app is develop for Redux and Type Script learning. Also create a template for further development. The project structure is based on the Rehabilitation app.
- A tutorial of todo using typescript(good to start): https://ts.chibicode.com/todo/
- TypeScript for Beginner Programmers(Not check yet): https://github.com/chibicode/TypeScript-for-Beginner-Programmers
- Redux official guide (Boring): https://redux.js.org/tutorials/fundamentals/part-1-overview
- TypeScript online exercise (Beginner): https://typescript-exercises.github.io/
- Know more about the react-natvie: https://www.reactnative.guide/3-react-native-internals/3.1-react-native-internals.html
- define a
type
to make sure that out input and output from a function is correct. - use readonly(
Readonly<'Object'>
) to make sure that the object's properties are not modified.Readonly<'Object'>
make whole object is readonly which like the map function in the javascript.Readonly<'Object'>
is for object, if we want to make the list is readonly, please use "readonly Todos[]
"
- Literal types: You can use exact values when specifying a type. This is called literal types.
- The value is fixed forever if th object is readonly.
// Returns an array where "done" is all true function completeAll( todos: readonly Todo[] ): CompletedTodo[] { // ... }
- The value is fixed forever if th object is readonly.
- The Above example is using a
CompletedTodo
(which is a literal type) to output a fixdone
value object list. - Intersection Types: deduplicate the properties in two types
- Like the && boolean operators, this one is tyep operators to combine two types.
- Union Types: use
A|B
to create union type. --> The type can work like aEnum type
in Android.type Place = 'home' | 'work' | { custom: string }
- Use
?
after the variable like code below to make the varible optional. (The variable like the?
in the Kotlin, but Kotlin is for null value checking)place?: Place
- Union type is good for condition handling. (在判斷的時候,所有的類型都應該覆蓋到,不然會報錯)
- Use