0Pricing
TypeScript Academy · Lesson

ES Modules (named vs default), re-exports

Understand named vs default exports/imports and how to re-export to build tidy module boundaries.

Intro

Goal: Use ES Modules confidently. You will export/import named and default symbols, then compose them with re-exports for tidy public APIs.

Named exports/imports

Named exports use export before declarations; import them with braces: import { name }.

// file: math.ts
export function add(a: number, b: number): number { return a + b }
export const PI = 3.14159

// file: app.ts
import { add, PI } from "./math"
console.log(add(2, 3), PI) // 5 3.14159

All lessons in this course

  1. ES Modules (named vs default), re-exports
  2. Ambient declarations (.d.ts) & third-party typings
  3. Path mapping & module resolution
← Back to TypeScript Academy