You want to create a new type FullConfig where all properties are required, but also want to add a new property timeout which is required. Which is the correct way to do this?
hard
A. type FullConfig = Partial<Config> & { timeout?: number };
B. type FullConfig = Required<Config> & { timeout?: number };
C. type FullConfig = Required<Config> & { timeout: number };
D. type FullConfig = Config & { timeout: number };
Solution
Step 1: Make all Config properties required
Use Required<Config> to make host, port, and secure mandatory.
Step 2: Add new required property timeout
Use intersection & with { timeout: number } to add a required timeout property.
Final Answer:
type FullConfig = Required<Config> & { timeout: number }; -> Option C
Quick Check:
Required + intersection adds required props [OK]
Hint: Combine Required<Type> & { newProp: type } for extra required props [OK]
Common Mistakes:
Using Partial instead of Required
Making new property optional when it should be required
Not combining types correctly
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.