Skip to content

Type-Only Import

In one line

'import type' imports only types — erased at runtime, preventing accidental inclusion of type-only modules in bundles.

In simple words

The import type syntax imports only types — no runtime code is emitted. This helps bundlers tree-shake unused modules and prevents accidentally importing a module for its types only.

Syntax: import type { Foo } from "./foo" or import { type Foo, bar } from "./foo" (inline type-only).

Use it when:

  1. You only need types from a module (no runtime values)
  2. You want to avoid circular dependency issues
  3. You want to ensure a module isn't included in the runtime bundle

The verbatimModuleSyntax compiler option (TS 5.0+) enforces using import type for type-only imports.

Example

typescript
// Type-only import — erased at runtime
import type { Config, Options } from "./config";

// Mixed import — value + type
import { render, type Component } from "./ui";

// Usage
function setup(config: Config, comp: Component) {
  render(comp); // render is a value, Component is a type
}

// After compilation, only `render` import remains
// import { render } from "./ui";

import type ensures Config, Options, and Component are erased at compile time. Only runtime values (render) remain in the output.

Common confusions

  • Confused with: regular import

    The difference: A regular import includes both the type and runtime value — the module is loaded at runtime. import type includes only the type — the import is erased, no runtime code is emitted. Use import type when you only need types, not values.

Related terms

Related Resources

Related Lessons

Decode error messages

Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.

View errors

← Back to glossary