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
index.ts
and:
  1. Create a type alias named Task with:
    • id: number
    • title: string
    • completed: boolean
  2. Create firstTask typed as Task with:
    • id: 1
    • title: 'Write tests'
    • completed: false
  3. Create secondTask typed as Task with:
    • id: 2
    • title: 'Ship release'
    • completed: true
  4. Export both: export { firstTask, secondTask }
You'll know you're done when both tasks match those exact values.

Please set the playground first

Loading "Object Types"
Loading "Object Types"
Login to get access to the exclusive discord channel.
Loading Discord Posts