0
0
Typescriptprogramming~10 mins

Combining utility types in Typescript - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to make all properties of the type optional using a utility type.

Typescript
type PartialUser = [1]<User>;
Drag options to blanks, or click blank then click option'
APartial
BRequired
CReadonly
DPick
Attempts:
3 left
💡 Hint
Common Mistakes
Using Required instead of Partial.
Using Readonly which makes properties readonly, not optional.
2fill in blank
medium

Complete the code to create a type with only the 'id' and 'name' properties from User.

Typescript
type UserIdName = [1]<User, 'id' | 'name'>;
Drag options to blanks, or click blank then click option'
ARecord
BOmit
CPartial
DPick
Attempts:
3 left
💡 Hint
Common Mistakes
Using Omit which excludes properties instead of selecting.
Using Partial which makes properties optional but does not select.
3fill in blank
hard

Fix the error in the code to make all properties readonly.

Typescript
type ReadonlyUser = [1]<User>;
Drag options to blanks, or click blank then click option'
ARequired
BPartial
CReadonly
DPick
Attempts:
3 left
💡 Hint
Common Mistakes
Using Partial which makes properties optional, not readonly.
Using Required which makes properties required, not readonly.
4fill in blank
hard

Fill both blanks to create a type that excludes 'password' and makes the rest readonly.

Typescript
type SafeUser = [1]<[2]<User, 'password'>>;
Drag options to blanks, or click blank then click option'
AReadonly
BPartial
COmit
DPick
Attempts:
3 left
💡 Hint
Common Mistakes
Reversing the order of utility types.
Using Pick instead of Omit.
5fill in blank
hard

Fill all three blanks to create a type that excludes 'password', makes the remaining properties optional, and makes them readonly.

Typescript
type CustomUser = [1]<[2]<[3]<User, 'password'>>>;
Drag options to blanks, or click blank then click option'
AReadonly
BPartial
COmit
DPick
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up the order of utility types.
Using Pick instead of Omit.