Courses / TypeScript
13. type-only imports/exports
Using import type / export type to avoid runtime import cycles and reduce bundle size.
JavaScript
type-only imports/exports
A syntax to import or export TypeScript/Flow types without creating a runtime dependency.
"I keep getting circular import errors or extra code in my bundle just because I referenced a type."
import type / export type tell the compiler to erase those imports/exports at runtime so they don't produce JS require/import calls; they exist only for type-checking.
"I keep getting circular import errors or extra code in my bundle just because I referenced a type."
import type / export type tell the compiler to erase those imports/exports at runtime so they don't produce JS require/import calls; they exist only for type-checking.