TypeScript Modules and Namespaces Quiz
A 30-question TypeScript quiz covering ES module imports, exports, module resolution rules, namespaces, namespace merging, ambient modules, and organizational patterns.
Question 1
How does TypeScript determine a file is a module?
Question 2
Modules provide:
Question 3
What does this export?
export const value = 10;Question 4
Which is true about modules?
Question 5
What syntax imports the default export?
// from module 'math'
export default function add(a: number, b: number) {}Question 6
A module can have:
Question 7
Which import is correct for a named export?
export const max = 100;Question 8
Wildcard imports create:
Question 9
Which extension does TypeScript try first when resolving imports?
import { x } from './utils';Question 10
Module resolution is influenced by:
Question 11
Namespaces are primarily used for:
Question 12
What does this declare?
namespace Tools {
export function log(msg: string) {}
}Question 13
Namespaces differ from modules because namespaces:
Question 14
What happens to these declarations?
namespace A { export const x = 1; }
namespace A { export const y = 2; }Question 15
Namespace merging allows:
Question 16
What does this declare?
declare module 'libA' {
export function run(): void;
}Question 17
Ambient modules are used for:
Question 18
Modules are preferred over namespaces because:
Question 19
Namespaces are still useful for:
Question 20
Why does this import fail?
import value from './lib';
// lib exports: export const value = 1;Question 21
Which is valid ES module syntax?
Question 22
What does this create?
export * from './utils';Question 23
Namespaces can be nested to:
Question 24
Which is true about namespace imports?
Question 25
Which is a recommended approach for application-scale code?
Question 26
Which is a property of modules?
Question 27
Namespaces are discouraged in modern applications mainly because:
Question 28
What do modules enforce?
Question 29
Namespace augmentation allows:
Question 30
Overall, modules and namespaces help developers:
