Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to add a new property to the existing interface.
Typescript
declare module 'some-library' { interface User { [1]: string; } }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a property name that already exists in the interface.
Forgetting to use 'declare module' syntax.
✗ Incorrect
We add the 'nickname' property to the User interface to augment it.
2fill in blank
mediumComplete the code to augment the global Window interface with a new method.
Typescript
declare global {
interface Window {
[1](): void;
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Adding a method with parameters when none are expected.
Not using 'declare global' to augment global interfaces.
✗ Incorrect
We add the 'alertUser' method to the Window interface to augment it.
3fill in blank
hardFix the error in the module augmentation by completing the missing keyword.
Typescript
import 'some-library'; declare [1] 'some-library' { interface Config { debugMode: boolean; } }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'namespace' instead of 'module' for module augmentation.
Omitting the keyword entirely.
✗ Incorrect
The 'module' keyword is required to augment an existing module.
4fill in blank
hardFill both blanks to correctly augment the Express Request interface with a new property.
Typescript
import 'express'; declare [1] 'express' { interface Request { [2]: string; } }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'namespace' instead of 'module' for augmentation.
Choosing a property name unrelated to sessions.
✗ Incorrect
Use 'module' to augment 'express' and add 'sessionId' property to Request interface.
5fill in blank
hardFill all three blanks to augment the React module by adding a new prop to the ButtonProps interface.
Typescript
import 'react'; declare [1] 'react' { interface ButtonProps { [2]?: boolean; } interface ButtonProps { [3]?: string; } }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'namespace' instead of 'module'.
Choosing invalid or unrelated prop names.
✗ Incorrect
Use 'module' to augment 'react' and add 'disabled' and 'variant' props to ButtonProps.