Syntax

TypeScript Import Only a Type Syntax

In TypeScript, import only a type: imports a type without importing runtime code — import type { User } from "./types";

Quick Answer

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

Import Only a Type

Code example
import type { User } from "./types";

Imports a type without importing runtime code.

Learn More

How to import only a type in TypeScript

  1. Open your TypeScript file or editor.
  2. Copy the example, then replace its sample names and values for your code.

TypeScript Import Only a Type Syntax

Use import type { User } from "./types";.

Related Syntax References

Frequently asked questions

What is the TypeScript syntax for import only a type?

Use this pattern: import type { User } from "./types";

Can I copy this TypeScript code example?

Yes. Use Copy code and adapt the example to your program.

Is this TypeScript syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify