Recall & Review
beginner
What is namespace merging in TypeScript?
Namespace merging is when two or more namespaces with the same name combine their contents into a single namespace. This allows you to split code into parts but use it as one.
Click to reveal answer
intermediate
Can interfaces and namespaces merge in TypeScript?
Yes! Interfaces and namespaces with the same name can merge. The namespace can add static members or helper functions to the interface.
Click to reveal answer
intermediate
What happens if two namespaces with the same name have conflicting members?
If two namespaces have members with the same name and type, they merge fine. But if types conflict, TypeScript will show an error.
Click to reveal answer
beginner
Show a simple example of namespace merging in TypeScript.
Example:
namespace MySpace {
export const a = 1;
}
namespace MySpace {
export const b = 2;
}
// Now MySpace has both 'a' and 'b' members.Click to reveal answer
beginner
Why use namespace merging instead of one big namespace?
Namespace merging helps organize code by splitting it into smaller parts. It also allows adding new members later without changing the original namespace.
Click to reveal answer
What does namespace merging allow you to do in TypeScript?
✗ Incorrect
Namespace merging combines multiple namespaces with the same name into a single namespace.
Can a namespace and a class with the same name merge in TypeScript?
✗ Incorrect
In TypeScript, a namespace and a class with the same name can merge, combining static members.
What happens if two merged namespaces have a member with the same name but different types?
✗ Incorrect
Conflicting member types in merged namespaces cause TypeScript to throw an error.
Which of these can be merged with a namespace?
✗ Incorrect
Interfaces and namespaces with the same name can merge in TypeScript.
Why might you use namespace merging?
✗ Incorrect
Namespace merging helps organize code by splitting it into smaller, manageable parts.
Explain how namespace merging works in TypeScript and give a simple example.
Think about how two parts with the same name combine their contents.
You got /2 concepts.
What are the benefits of using namespace merging instead of one large namespace?
Consider how splitting helps keep code clean and flexible.
You got /3 concepts.