-
Notifications
You must be signed in to change notification settings - Fork 516
Open
Description
Issue Overview
03_02e The source code doesn't match the video source;
Possible Solution
add extra code if you want, but keep the code from the video in the source;
type ContactName = string;
type ContactStatus = "active" | "inactive" | "new"
type ContactBirthDate = Date | number | string
interface Contact {
id: number;
name: ContactName;
birthDate?: ContactBirthDate;
status?: ContactStatus;
email?: string;
}
let primaryContact: Contact = {
id: 12345,
name: "James Johnson",
status: "active"
}
type ContactFields = keyof Contact
function getValue<T, U extends keyof T>(source: T, propertyName: U) {
return source[propertyName]
}
const value = getValue({min: 1, max: 200}, "");
// function toContact(nameOrContact) {
// if (typeof nameOrContact === "string") {
// return {
// id: 0,
// name: nameOrContact,
// status: "active"
// }
// }
// else if (typeof nameOrContact === "object") {
// return {
// id: nameOrContact.id,
// name: nameOrContact.name,
// status: nameOrContact.status
// }
// }
// else {
// return null;
// }
// }
Metadata
Metadata
Assignees
Labels
No labels