Skip to content

How about adding Partial Example? #35

Closed
@gaki2

Description

@gaki2

Hey @mattpocock .
Thanks for your effort and time spent on this course.
I'd suggest adding Partial Example.
What do you think of that?

/**
 * How do we make _only_ the id property mandatory?
 */
interface User {
  id: string;
  firstName: string;
  lastName: string;
  address: string;
  age: number;
  sex: string;
}

/**
 * Answer1 - optional properties
 */
interface User {
  id: string;
  firstName?: string;
  lastName?: string;
  address?: string;
  age?: number;
  sex?: string;
};

/**
 * Answer2 - Partial properties
 */
interface User {
  id: string;
} & Partial<{
  firstName: string;
  lastName: string;
  address: string;
  age: number;
  sex: string;
}>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions