Skip to content

consistent-type-imports

Reports an import in a TypeScript file whose names are all used only as types (also in typeof of a type) and is not written import type, a mixed import with such a name (the value names stay in an import), and the type form import("a").B. A name that is not used at all is not reported.

An import used only for types is erased when the file is compiled, but the compiler cannot always know that, so a plain import may stay as a real load with side effects, and a cycle between files can appear that the types did not need. import type states it, so the import is always removed.

To fix, write import type { T } from 'x' or import { type T } from 'x'.

Reported
import { A, B } from "a";
import C, { D } from "c";
import * as NS from "ns";
import E from "e";
import type { T } from "t";
import { type U, V } from "u";
import { W, Y } from "w";
import { X } from "x";
import Z from "z";
export { X };
let a: A, b: B, c: C, d: D, ns: NS.Thing, w: W = 1, q: typeof E, t: T, u: U, y: Y;
const v = V, z = Z;
type I = import("m").I;
js:
lint:
rules:
consistent-type-imports: warn # off (default), warn, error

Enabled by the presets: js/biome-recommended.

Suppress one line with sudsy-disable-next-line consistent-type-imports in a comment of the file’s language.

The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.

Tool Rule Match What differs
typescript-eslint consistent-type-imports partial the options keep their defaults (prefer type-imports, fixStyle separate-type-imports); emitDecoratorMetadata is not known, so a file with decorators is checked