Skip to main content

SKY-U008 · Dead code

Unused TypeScript namespace member

Low

A variable, type or interface exported from an export namespace block that no file reads. Other members of the same namespace are used, so the namespace itself is live.

Languages
TypeScript
Turned on by
skylos . (every scan)
Quality gate
counted toward the gate limits (full and diff scans). Reported in unused_variables with its own SKY-U008 ID; counts toward max_dead_code, which is unlimited by default.
Finding type
review
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

Why it matters

Namespaces often collect constants and types for one feature. An unread member looks like supported behaviour and keeps its initializer and dependencies alive.

What Skylos flags

src/shapes.ts · TypeScriptReported on line 3
export namespace Shapes {  export const Circle = "circle";  export const Square = "square";}
src/main.ts · TypeScript
import { Shapes } from "./shapes"; console.log(Shapes.Circle);
package.json · JSON
{"name": "shapes-app", "private": true, "main": "src/main.ts"}

What Skylos leaves alone

src/shapes.ts: same as in the flagged example.

src/main.ts · TypeScript
import { Shapes } from "./shapes"; console.log(Object.values(Shapes));

package.json: same as in the flagged example.

Why Skylos leaves it alone

Object.values(Shapes) reads every member, so none can be shown to be unused.

How Skylos decides

  1. Checks export namespace blocks in internal modules (the SKY-E004 notion of a module that is not public).
  2. Combines member reads from every file (Shapes.Circle, type positions such as Shapes.Kind, destructuring) with references in the namespace body. Nested namespaces are followed (Shapes.Inner.x).
  3. Abstains for the whole namespace when it escapes as a value, is merged with another declaration, is ambient, is tagged @public, @alpha or @beta, no other file imports it, or a types-only wildcard export publishes its module's declarations. Tagged members stay live. Imports in Vue, Svelte and Astro scripts, HTML module scripts and MDX count as reads like any other file's.
  4. Functions, classes and enums in a namespace keep their SKY-U001/SKY-U004 findings. analysis_summary.namespace_member_analysis records checked namespaces and abstentions.

How to fix it

Remove the unread member.

src/shapes.ts · TypeScript · the fix, against the flagged file
export namespace Shapes {  export const Circle = "circle";Removed:   export const Square = "square";}

When it can be wrong

  • Code outside the scanned project can read a member of a namespace that an internal module exports.

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-U008] on the member's line.

  • Set [tool.skylos] ignore = ["SKY-U008"] to disable this rule project-wide.

From the Skylos rule handbook, Skylos 5.8.0 (commit 5b880b0). All rules.