TypeScript · Classes and modules

Type-only import

Imports only types so the statement is erased and never creates a runtime dependency.

Syntax
import type { User } from "./types"

Example

Example
// import type { User } from "./types";
console.log("Type-only imports make the dependency graph honest.");

More in this group

abstract class Access modifiers Class Declaration file implements Namespace import readonly field

Learn this in the course

Reference pages are the quick answer. The course explains the why, shows the full example and ends with a challenge.

Open the course