Skip to content

How about adding Partial Example? #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gaki2 opened this issue Sep 10, 2022 · 1 comment
Closed

How about adding Partial Example? #35

gaki2 opened this issue Sep 10, 2022 · 1 comment

Comments

@gaki2
Copy link

gaki2 commented Sep 10, 2022

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;
}>
@mattpocock
Copy link
Collaborator

Thanks for the suggestion, but this will likely live in a separate module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants