TypeScript TS1484: 'X' is a type and must be imported using a type-only import
TS1484 means the compiler cannot tell if an imported name survives to runtime. Mark type imports inline, fix barrels, and keep decorated signatures intact.

Introduction & Quick Summary
TypeScript refuses to compile with a message like this:
src/api/users.ts:3:10 - error TS1484: 'User' is a type and must be imported
using a type-only import when 'verbatimModuleSyntax' is enabled.It appears the moment "verbatimModuleSyntax": true lands in tsconfig.json, or when a framework starter turns it on for you. The compiler is not saying the import is unused or misspelled. It is saying it cannot tell whether the name survives to runtime, so it refuses to guess.
Quick answer: mark the import as types-only, either as a statement or inline:
import type { User } from "./types";
import { type Role, parseUser } from "./types"; // mixed module, one statementBoth are erased at emit. Use the inline form when one module exports both types and values, because parseUser stays a real import and Role disappears.
Where it shows up most often: a types.ts imported into a route handler, import { ReactNode } from "react" next to a hook, NestJS classes used only in constructor parameter types, index.ts barrels, and codemods that added import type everywhere.
Core Mechanics, Signatures & Reproducible Setup
Before TypeScript 5.0, the compiler decided per statement whether an import had to survive by checking how each binding was used, then deleted the statement if nothing remained. That speculation is import elision. It is invisible in a normal build and breaks in two places: a transpiler without type information (esbuild, SWC, Babel) cannot repeat it, and a module imported only for side effects can vanish.
verbatimModuleSyntax removes the speculation. Every import and export statement is emitted as written, minus anything you explicitly marked type. Nothing is inferred, nothing is dropped.
{
"compilerOptions": {
"module": "esnext",
"moduleResolution": "bundler",
"verbatimModuleSyntax": true,
"isolatedModules": true,
"target": "es2022"
}
}Reproduce it in one directory, which is worth doing before touching a large tree:
npm i -D typescript@5.9
cat > types.ts <<'EOF'
export interface User { id: string; email: string }
export function parseUser(raw: unknown): User { return raw as User }
EOF
cat > main.ts <<'EOF'
import { User, parseUser } from "./types";
const u: User = parseUser({});
console.log(u);
EOF
npx tsc --noEmit --strict --verbatimModuleSyntax --module esnext --moduleResolution bundler main.tsThe flag also fixes which files are ES modules. A file containing import or export syntax is emitted as ESM, full stop; a .cts file is CommonJS, where only export = and import x = require() are allowed. Hence the companion errors TS1283/TS1286: ESM syntax is not allowed in a CommonJS module when verbatimModuleSyntax is enabled.
Key Comparison Table
The flag replaced a family of older options. This is the mapping, with what still compiles:
| Setting | Versions | Behaviour | Status |
|---|---|---|---|
importsNotUsedAsValues: "remove" | 4.5 – 5.4 | elides unused imports (default) | removed in 5.5 |
importsNotUsedAsValues: "error" | 4.5 – 5.4 | forces import type for type-only names | removed in 5.5 |
preserveValueImports: true | 4.5 – 5.4 | never elides a used-binding import | removed in 5.5 |
verbatimModuleSyntax: true | 5.0+ | emits statements verbatim, erases only type imports | current |
inline type modifier | 4.5+ | marks one specifier as type-only | current |
What each import form emits:
| Written | With the flag on | With it off | Use when |
|---|---|---|---|
import type { T } from "m" | nothing | nothing | module supplies only types |
import { type T, fn } from "m" | import { fn } from "m" | import { fn } from "m" | module mixes both |
import { T, fn } from "m" | unchanged, both names | import { fn } if T is a type | both are values |
The errors that share this root cause:
| Message | Meaning | Fix |
|---|---|---|
TS1484 | a type name imported as a value | add type to the specifier or statement |
TS1205 | re-exporting a type when isolatedModules is on | export type { X } from "..." |
TS1361 | erased name used as a value | drop type for that specifier |
TS1272 | type in a decorated signature with isolatedModules | import type, and keep metadata in mind |
TS1286 / TS1287 | ESM syntax inside a CommonJS file | rename to .mts or switch to require |
Practical Edge Cases, Error Fixes & Deep Dive Code Examples
1. Mixed modules: the inline modifier beats two statements
Two imports from one path is legal but invites a third:
import type { User, Role } from "./types";
import { parseUser } from "./types";
import { type User, type Role, parseUser } from "./types"; // preferredimport { type FC, useState } from "react" is the everyday version of this rule and survives the flag unchanged.
2. Codemods: convert a tree and keep the diff readable
The consistent-type-imports rule rewrites automatically; then compile:
npx eslint . --ext .ts,.tsx --fix \
--rule '{"@typescript-eslint/consistent-type-imports":["error",{"prefer":"type-imports","fixStyle":"inline-type-imports"}]}'
npx tsc -p . --noEmitinline-type-imports yields one statement per module, so one line changes per edit. separate-type-imports yields the two-statement form. The compiler accepts both; only the review cost differs.
3. Barrels need export type
export { User, Order } from "./models"; // TS1205 once isolatedModules is on
export { type User, type Order } from "./models"; // fixed
export type { User as AppUser } from "./models"; // rename while re-exportingexport * from "./models" is safe: the compiler never has to classify names it does not enumerate. That is why some codebases enable the flag with zero changes.
4. Decorated signatures in NestJS, Angular and TypeORM
emitDecoratorMetadata writes constructor parameter types into runtime metadata, so those types must exist as values — while isolatedModules plus decorators pushes the other way. The rule that resolves it:
import { Repository } from "typeorm"; // class used as a value: design:paramtypes
import type { User } from "../entities/user"; // only inside a generic argument
@Injectable()
export class UserService {
constructor(private readonly repo: Repository<User>) {}
}Mark the class itself import type and metadata records Object; the build stays green and dependency injection fails at runtime with "Nest can't resolve dependencies".
5. Test runners and transpilers that ignore types
Vitest, babel-jest, @swc/jest and tsx strip types without checking them. With the flag on, the source already declares what is erasable, so their output matches tsc:
import { describe, it, expect, vi } from "vitest";
import type { Mock } from "vitest";
import { UserService } from "./user.service";
import type { User } from "./user";A test failing with SyntaxError: The requested module './types' does not provide an export named 'User' still has a value import for a type-only module. Add type; the logic does not change.
6. Const enums and namespaces
import type * as ts from "typescript" is legal when you touch only its types. const enum is the trap: with isolatedModules another file cannot inline it, and TS2748 appears. Replace it with a literal union, which needs no runtime import at all:
export const ROLES = ["admin", "editor", "viewer"] as const;
export type Role = (typeof ROLES)[number];Common Compilation/Runtime Mistakes & Version Gotchas
Enabling the flag under "module": "commonjs". Every file with ESM syntax then fails with TS1286. Turn it on with "module": "esnext" or "node16" and migrate the few files that genuinely need require.
Marking a class import type and later calling new, instanceof, or using it as a decorator. TS1361 is the friendly version of that mistake. The unfriendly version is a DI container resolving it by string at runtime.
Expecting the flag to make side-effect imports safer. It adds nothing; it only stops deleting. import "./polyfills" was always preserved. What changes is that import { unused } from "pkg" is no longer silently dropped, which can expose packages that had been tree-shaken by accident.
Version boundaries. The inline modifier arrived in 4.5, verbatimModuleSyntax in 5.0, and importsNotUsedAsValues/preserveValueImports were removed in 5.5 — a tsconfig.json copied from a 2022 article now fails with Unknown compiler option. TypeScript 5.5 and later also mark type-only imports in the .d.ts output, so declaration consumers see the same classification.
CommonJS packages that use export =. Under ESM emit these need import pkg from "pkg" with esModuleInterop, or import pkg = require("pkg") in a .cts file. A default import that worked with allowSyntheticDefaultImports alone can start failing once the module format is fixed.
Verify the emit, do not reason about it. Compile with --outDir dist and open the output: type-only lines are gone, everything else is byte-for-byte the source. Compare two builds with the text diff tool rather than the input, since only the emitted file reaches the runtime. Import linters that parse source text need patterns such as ^import\s+(?!type\b); test them on the regular expression tester before a repository-wide codemod.
Reference material: verbatimModuleSyntax and the TypeScript 5.0 release notes.
Official references
primary documentationThe TypeScript documentation that defines the behaviour this guide explains.
Try matching browser tools
All toolsSmall utilities that fit TypeScript work — they run entirely in this browser tab, so nothing you paste leaves your device.
Related TypeScript guides
All TypeScript guidesTypeScript TS2349: This expression is not callable
TS2349 means the value has no call signature at that point. Narrow unions, fix module default imports and guard optional calls instead of asserting.
TypeScript: Cannot find name 'process' with @types/node
TS2304 on process or Buffer means the compiler has no Node declarations. Install @types/node, stop excluding it, and align its version to the runtime.
TypeScript TS2532: Object is possibly 'undefined'
TS2532 means strict null checks cannot prove a value exists before reading through it. Guard it, add optional chaining, or narrow the type at the source.
TypeScript TS18046: 'e' is of type 'unknown'
TS18046 comes from useUnknownInCatchVariables: a caught error is unknown, not any. Narrow it with instanceof or a type guard before reading message.
More in TypeScript
All TypeScript guidesThe guides filed next to this one in TypeScript, in library order.