๋ฐ˜์‘ํ˜•

๐Ÿ’™ Type Challenges/Typescript Exercises 7

[TS] TypeScript Exercises 7 ํ•ด์„ ๋ฐ ํ’€์ด

Intro Filtering was completely removed from the project. It turned out that this feature was just not needed for the end-user and we spent a lot of time just because our office manager told us to do so. Next time we should instead listen to the product management. Anyway we have a new plan. CEO's friend Nick told us that if we randomly swap user names from time to time in the community, it would..

[TS] TypeScript Exercises 5 ํ•ด์„ ๋ฐ ํ’€์ด

Intro Filtering requirements have grown. We need to be able to filter any kind of Persons. ํ•„ํ„ฐ๋ง ์š”๊ตฌ์‚ฌํ•ญ์ด ๋Š˜์—ˆ์Šต๋‹ˆ๋‹ค. ์ด์ œ Person์˜ ๋ชจ๋“  ์ข…๋ฅ˜๋ฅผ ๊ตฌ๋ถ„ํ•ด์•ผํ•ฉ๋‹ˆ๋‹ค. Exercise Fix typing for the filterPersons so that it can filter users and return User[] when personType='user' and return Admin[] when personType='admin'. Also filterPersons should accept partial User/Admin type according to the personType. `criteria` argument sh..

[TS] TypeScript Exercises 5 ํ•ด์„ ๋ฐ ํ’€์ด

Intro Time to filter the data! In order to be flexible we filter users using a number of criteria and return only those matching all of the criteria. We don't need Admins yet, we only filter Users. ๋ฐ์ดํ„ฐ๋ฅผ ์„ ๋ณ„ํ•  ์ฐจ๋ก€์ž…๋‹ˆ๋‹ค! ๋ณด๋‹ค ์œ ์—ฐํ•ด์ง€๊ธฐ ์œ„ํ•ด ์šฐ๋ฆฌ๋Š” ๊ธฐ์ค€์„ ํ‘œ์‹œํ•˜๋Š” ์ˆซ์ž๋ฅผ ์ด์šฉํ•˜์—ฌ ์œ ์ €๋“ค์„ ํ•„ํ„ฐ๋งํ•˜๊ณ , ์˜ค์ง ์ด ๋ชจ๋“  ๊ธฐ์ค€์— ๋งž๋Š” ์œ ์ €๋“ค๋งŒ ๋ฆฌํ„ดํ•ด์•ผํ•ฉ๋‹ˆ๋‹ค. ์•„์ง Admin๋“ค์€ ํ•„์š”ํ•˜์ง€ ์•Š๊ณ  User๋“ค๋งŒ ํ•„ํ„ฐ๋งํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค. Exercise Without duplicating type structures, modify filterUsers functio..

[TS] TypeScript Exercises 4 ํ•ด์„ ๋ฐ ํ’€์ด

Intro As we introduced "type" to both User and Admin it's now easier to distinguish between them. Once object type checking logic was extracted into separate functions isUser and isAdmin - logPerson function got new type errors. ์œ ์ €์™€ ์–ด๋“œ๋ฏผ์— ๋Œ€ํ•ด type์„ ์†Œ๊ฐœํ–ˆ๋“ฏ์ด, ์ด์ œ ์ด ๋‘˜์„ ๊ตฌ๋ถ„ํ•˜๋Š”๊ฑด ์‰ฌ์›Œ์กŒ์Šต๋‹ˆ๋‹ค. ๋กœ์ง์„ ๊ฒ€์‚ฌํ•˜๋Š” ๊ฐ์ฒด ํƒ€์ž…์„ ์ถ”์ถœํ•ด์„œ isUser๊ณผ isAdmin ํ•จ์ˆ˜์— ๋ถ„๋ฆฌํ•ด์„œ ๋„ฃ์—ˆ๋”๋‹ˆ logPerson ํ•จ์ˆ˜์— ์ƒˆ๋กœ์šด ํƒ€์ž…์—๋Ÿฌ๊ฐ€ ์ƒ๊ฒผ์Šต๋‹ˆ๋‹ค Exercise Figure out how to help TypeScrip..

[TS] TypeScript Exercises 3 ํ•ด์„ ๋ฐ ํ’€์ด

Intro Since we already have some of the additional information about our users, it's a good idea to output it in a nice way. ์ด๋ฏธ ์œ ์ €์˜ ์ถ”๊ฐ€์ ์ธ ์ •๋ณด๋ฅผ ์•Œ๊ณ  ์žˆ๊ธฐ ๋•Œ๋ฌธ์—, ๋ฉ‹์ง„ ๋ฐฉ๋ฒ•์œผ๋กœ ์ด๋ฅผ ํ‘œ์ถœํ•˜๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™๋‹ค Exercise Fix type errors in logPerson function. logPerson function should accept both User and Admin and should output relevant information according to the input: occupation for User and role for Admin. logPerson ํ•จ์ˆ˜์˜ ํƒ€์ž…์—๋Ÿฌ..

[TS] TypeScript Exercises 2 ํ•ด์„ ๋ฐ ํ’€์ด

Introduce All 2 users liked the idea of the community. We should go forward and introduce some order. We are in Germany after all. Let's add a couple of admins. Initially, we only had users in the in-memory database. After introducing Admins, we need to fix the types so that everything works well together. ๋‘๋ช…์˜ ์œ ์ € ์ „๋ถ€ ์ปค๋ฎค๋‹ˆํ‹ฐ์˜ ์•„์ด๋””์–ด๊ฐ€ ๋งˆ์Œ์— ๋“ค์—ˆ๊ณ , ์šฐ๋ฆฌ๋Š” ์ด์ œ ์†Œ๊ฐœ๋ฅผ ํ•ด์•ผํ•ฉ๋‹ˆ๋‹ค. admin ๋ช‡๋ช…์„ ์ถ”๊ฐ€ํ•ด๋ด…์‹œ๋‹ค. ์ฒ˜์Œ์— ์šฐ๋ฆฌ๋Š” ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์—๋งŒ ์œ ์ €๋ฅผ ์ €์žฅ..

[TS] TypeScript Exercises 1 ํ•ด์„ ๋ฐ ํ’€์ด

Introduce We are starting a small community of users. For performance reasons we have decided to store all users right in the code. This way we can provide our developers with more user-interaction opportunities. With user-related data, at least. All the GDPR-related issues will be solved some other day. This would be the basis for our future experiments during these exercises. ์šฐ๋ฆฌ๋Š” ์ด์ œ ์œ ์ €๋“ค์„ ์œ„ํ•œ ์ž‘์€..

๋ฐ˜์‘ํ˜•