Careeroza
Type-only Imports
import type
import type { X } imports only a type. It is always removed from the JavaScript output, so it never causes a runtime import or a circular-dependency problem. You can also mark single names: import { type X, y }.
import type { Product } from "./models/product"; // erased completely
import { type Order, createOrder } from "./orders"; // Order erased, createOrder kept
export type { Product }; // type-only re-exportverbatimModuleSyntax
With "verbatimModuleSyntax": true in tsconfig.json (recommended for new projects, used by Vite and many Next.js setups), TypeScript requires import type for types. The rule is simple: anything without type stays in the output, anything with type is removed.
{
"compilerOptions": {
"verbatimModuleSyntax": true
}
}Tip: ESLint rule @typescript-eslint/consistent-type-imports adds type automatically on save.
Using a Type-only Import as a Value
Example
A class imported with import type can be used in annotations, but not with new (TS1361).
import type { EventEmitter } from "node:events";
function attach(bus: EventEmitter): void {
bus.on("x", () => {});
}
const bus = new EventEmitter();Compiler output (tsc)
Line 7: error TS1361: 'EventEmitter' cannot be used as a value because it was imported using 'import type'.