ReviseAlgo Logo

Modules & Namespaces

ES Modules in TypeScript

Use standard import/export syntax and type-only imports.

Last Updated: July 29, 2026 10 min read

TypeScript uses standard ES module syntax (import and export) for modularity and tree-shaking.

1. Introduction & Architecture

2. Deep Dive & Core Concepts

import type guarantees that imported symbols are erased completely from transpiled JS output.

3. Basic Code Example

4. Advanced Production Patterns

5. Interactive Code Playground

console.log("ES Modules provide clean type-safe imports.");

6. Common Pitfalls & Edge Cases

Note: Use import type to avoid circular runtime dependency imports when only importing types.

7. Interview Q&A & Quizzes

Q: What is the benefit of 'import type'?

A: It explicitly marks imports that must be completely removed during compilation.

8. Summary Comparison Table

Import SyntaxJS Output
import { val }Retained JS Require/Import
| import type { T } | Erased completely |