A. type ReadonlyOptional<T> = { readonly [P in keyof T]?: T[P] }
B. type ReadonlyOptional<T> = { [P in keyof T]?: readonly T[P] }
C. type ReadonlyOptional<T> = { [P in keyof T]-?: readonly T[P] }
D. type ReadonlyOptional<T> = { readonly [P in keyof T]-?: T[P] }
Solution
Step 1: Combine readonly and optional modifiers
To make properties readonly and optional, use readonly before the property and ? after the property name.
Step 2: Analyze each option
type ReadonlyOptional<T> = { readonly [P in keyof T]?: T[P] } correctly places readonly before and ? after the property name. Others misuse readonly or optional placement.
Final Answer:
type ReadonlyOptional<T> = { readonly [P in keyof T]?: T[P] } -> Option A
Quick Check:
readonly before, optional after property name [OK]
Hint: Put readonly before and ? after property name [OK]
Common Mistakes:
Placing readonly after the type
Using -? which removes optional
Confusing readonly with optional placement
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.