lightsoutAlpha

import-type-only

an import used only in type positions declared without `import type`

Deterministic checkblocking by defaultbasecode

The argument

The lint preset is binding even where the repo's lint config does not yet enforce it. These rules are mechanical — they are stated here once, without prose, and violations are violations whether or not a linter catches them:

  • import type for type-only imports — anything used only in type positions (annotations, parameter types, generic arguments) imports with import type, so it erases at compile time. On a decorated declaration — a decorated class's constructor parameters, a decorated method's parameters, a decorated property's type — the referenced names are runtime values (decorator metadata is how DI and validation read them), so they are imported as values; import type there is the bug, not the fix.

The proof

fail
import { Invoice } from './Invoice';

interface Params {
	invoice: Invoice;
}

export const getChargeLabel = ({ invoice }: Params): string => invoice.label;
pass
export const formatAmount = ({ amount }: { amount: number }): string => `${amount}`;

Turn it down

Both lines go in your lightsout.config.json.

"standards-checks": { "import-type-only": "advisory" }
"standards-checks": { "import-type-only": "off" }