Type-Only Imports and Exports
Use import type to avoid runtime overhead.
Welcome
Type-only imports and exports (import type / export type) were introduced in TypeScript 3.8 to give developers explicit control over what is a runtime dependency and what is only a type.
Why Type-Only Matters
Regular imports may include runtime code. If you only need the type, the import can be erased entirely from the compiled output.
import { User } from './models'; // includes runtime binding
import type { User } from './models'; // compile-time only, erasedAll lessons in this course
- ES Module Syntax: import and export
- Re-exports and Barrel Files
- Type-Only Imports and Exports
- Namespaces vs Modules: Modern Usage