deslop/unused-type
Disallow exporting a type/interface that no other module imports (opt-in, requires reportTypes).
- Category: Dead Code
- Severity: warn
- Source:
deslop-js - Framework: global
- Enabled when: react-doctor deadCode analysis enabled (default true); whole-project scan only — skipped in --diff/--staged modes
- Documentation: https://github.com/millionco/deslop-js
Validation prompt
Use this to decide whether a fired diagnostic is real or a false positive.
Fires from deslop's detectDeadExports only when config.reportTypes is enabled (it defaults to false, so a normal scan flags ZERO type-only exports — deslop suppresses them by default as barrel re-export noise per the export type * from "./types" pattern); with reportTypes on, it fires on an export whose isTypeOnly is true (a top-level export type/export interface, or any TSTypeAliasDeclaration/TSInterfaceDeclaration export) that has no usageMap hit for its module-path::name key and is not referenced as a local identifier, where the EXPORTING module itself is reachable and is not a .d.ts declaration file, and the export is neither a * namespace re-export nor an aliased pass-through re-export, and the file is not an entry point unless includeEntryExports is set; the finding carries no kind field. False positive: a published package's public type API where the type is part of the library's external surface and is consumed only by downstream/external consumers (or via generated .d.ts) that the in-project import graph cannot observe — suppress when the file is a real package entry/barrel and the type is intentionally exported for outside callers.
Fix prompt
Use this once validation confirms the diagnostic is real.
If nothing in-repo imports the type, delete the export keyword and keep it local when a same-file declaration still references it (type Foo = ... instead of export type Foo = ...), or remove the declaration entirely when it is fully dead; if it is genuinely public, move it into an entry-point/barrel matched by entryPatterns or run the scan with includeEntryExports so the API surface is treated as intentional rather than dead — and note this type-only check only runs at all when reportTypes is turned on, so leave reportTypes off if you are not auditing a type-heavy package. Stray exported types accumulate as dead surface that misleads readers into thinking they are part of a contract. See https://github.com/millionco/deslop-js