TypeScript · Middle · Question 18 of 75
How do namespaces (namespace) differ from ES modules?
- ✓Correct answer: Namespaces are a legacy way of organizing code; modules are used now
- 2Namespaces are a new ECMAScript standard replacing
import/export - 3They're synonyms: the compiler converts one into the other
Explanation
Namespaces predate ES modules and create objects at runtime. Code is now organized into files with import/export, while declare namespace is sometimes used in declarations to describe global libraries. Namespaces aren't compatible with erasableSyntaxOnly.