Object Types
Object Types
π¨βπΌ We're repeating the same object shape in a few places. Let's give that
shape a name so we can reuse it.
π¦Ί A type alias lets us name an object type. We'll go deeper on type aliases
in the Type Safety workshop, but this small intro will make later steps easier.
π¨ Open
and:
- Create a type alias named
Taskwith:id:numbertitle:stringcompleted:boolean
- Create
firstTasktyped asTaskwith:id:1title:'Write tests'completed:false
- Create
secondTasktyped asTaskwith:id:2title:'Ship release'completed:true
- Export both:
export { firstTask, secondTask }
You'll know you're done when both tasks match those exact values.