SKY-E004 · Dead code
Unnecessary TypeScript/JavaScript export
An export that no other project file uses. It covers a value used only inside its own file, a re-export entry (export { a } from "./a") that nothing requests, and an exported TypeScript type or interface that no file imports from its module, including one used only in its own file.
- Languages
- TypeScript, JavaScript
- Turned on by
skylos .(every scan)- Quality gate
- counted toward the gate limits (full and diff scans). Reported in
unused_exports. Counts towardmax_dead_code, which has no limit by default, so it only fails a gate where you set one. - Finding type
- review
Why it matters
An unnecessary export widens a module's interface. Readers assume another file depends on it, so dead types and helpers survive refactors and keep their own dependencies alive.
What Skylos flags
export interface LegacyCartLine { sku: string; qty: number;} export function cartTotal(prices: number[]): number { return prices.reduce((sum, price) => sum + price, 0);}import { cartTotal } from "./cart"; console.log(cartTotal([1, 2]));{"name": "shop-web", "private": true, "main": "src/main.ts"}What Skylos leaves alone
export interface CartLine { sku: string; qty: number;} export function cartTotal(lines: CartLine[]): number { return lines.reduce((sum, line) => sum + line.qty, 0);}import { cartTotal } from "./cart"; console.log(cartTotal([{ sku: "a", qty: 1 }]));Why Skylos leaves it alone
CartLine is the parameter type of cartTotal, which another file imports. A type in the shape of a requested export stays exported so callers can name it.
How Skylos decides
- Builds the project's module demand: named, default, type-only and namespace-member imports,
import("./m").Ttype references, re-exports andexport *chains. A name is unnecessary when no file requests it from the module. - Public modules stay silent: package.json
main,module,types,exports,binandbrowsertargets, tool, framework and test entries, files named by path,index/main/cliat a package root, modules no file imports and modules consumed whole. - A type stays silent when it is merged with a value of the same name, lives in a
.d.tsfile or adeclare global/declare moduleblock, or is named in the shape of a value export another file requests. A requested type does not keep the types it mentions. @public,@alpha,@betaand@aliasJSDoc tags mark published API and are never reported;@internalgives no protection.- Vue, Svelte and Astro component scripts, inline
<script type="module">blocks in HTML and MDXimport/exportstatements are read as text and request their names like any importer. A part that does not parse (another script language, a syntax error, an MDXimport()expression, a Marko template) holds back only the modules its text names. Only an unreadable consumer turns the check off. - A wildcard export with only a
typescondition publishes each module's declarations: its type exports stay silent, its value exports are still checked. Files in__testfixtures__/__fixtures__folders are test data and never reported.
How to fix it
Remove the unused type, or drop its export keyword when the file still uses it.
Removed: export interface LegacyCartLine {Removed: sku: string;Removed: qty: number;Removed: }Removed: export function cartTotal(prices: number[]): number { return prices.reduce((sum, price) => sum + price, 0);}When it can be wrong
- Code outside the scanned project (another repository, a code generator that reads types by name) can consume an export Skylos cannot see.
Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.
How to silence it
Add
// skylos: ignore[SKY-E004]on the export's line.Set
[tool.skylos] ignore = ["SKY-E004"]to disable this rule project-wide.