consistent-type-imports
What it does
Section titled “What it does”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.
Why it matters
Section titled “Why it matters”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'.
Example
Section titled “Example”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;Configuration
Section titled “Configuration”js: lint: rules: consistent-type-imports: warn # off (default), warn, errorEnabled 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.
Upstream equivalents
Section titled “Upstream equivalents”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 |