Skip to content

Conversation

@htrung1303
Copy link

Mong anh bửa nhẹ tay 🙏

Copy link
Owner

@phantien133 phantien133 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TrungPH/ex2.ts Outdated
console.log(` - ${person.name}, ${person.age}`);
}

persons.forEach(logPerson); No newline at end of file
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

config editor auto add empty line vào cuối file đi em

TrungPH/ex4.ts Outdated
export function logPerson(person: Person) {
let additionalInformation: string = '';
if (isAdmin(person)) {
additionalInformation = (person as Admin).role;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ntn hợp lý, k sai
cơ mà làm các bài sau rồi, e có để cách ng ta dùng hàm để xác định type luôn cho 1 object k?
check rồi update thử xem

TrungPH/ex6.ts Outdated
);
}

export function getObjKeys<T extends object>(obj: T): (keyof T)[] {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

T extends object thì thôi T là đc e ạ

return Object.keys(obj) as (keyof T)[];
}

export function filterPersons(persons: Person[], personType: string, criteria: Partial<Person>): Person[] {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

có cách nào để xác định đc luôn khi gọi hàm thfi object trả về là User[] hay Admin[] luôn k em
vì ngay khi truyền personType là đã xác định đc r

TrungPH/ex9.ts Outdated
}
);

type AdminsApiResponse = (
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thử dùng generic type ở ApiResponse để tránh lặp lại 2 type mới khá trùng nhau ntn đc k e

@phantien133
Copy link
Owner

@htrung1303 update phát em

@htrung1303
Copy link
Author

@htrung1303 update phát em

@phantien133 Em done anh oi

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

Successfully merging this pull request may close these issues.

2 participants