Skip to main content
ai-slop/duplicate-type-declarationmanual fix

Duplicate exported type.

The same exported `interface` or `type` alias, with the same name and body, declared in two TypeScript files. Two sources of truth for one shape.

Flagged shape and clean shape.

Each example shows the exact code shape the rule is looking for, then the smallest version that keeps the intent without hiding risk or adding noise.

duplicate-type-declaration.ts
✗ Flagged
// src/billing/types.ts
export interface Customer { id: string; email: string }

// src/email/send-receipt.ts
export interface Customer { id: string; email: string }
Why this trips

Deterministic AST match across files: normalizes every exported interface and type alias in `.ts`/`.tsx` files and flags a declaration whose name and text match one already seen in another file.

duplicate-type-declaration.ts
✓ Clean
// src/billing/types.ts
export interface Customer { id: string; email: string }

// src/email/send-receipt.ts
import type { Customer } from '../billing/types'
What changed

Keep one exported type and import it where it is needed.

Agents declare types locally for the file they are working in instead of finding the existing one. The copies drift as soon as one is edited.

How this rule is justified.

Rule id

ai-slop/duplicate-type-declaration

Enforcing engine

ai-slop

Detector strategy

Deterministic AST match across files: normalizes every exported interface and type alias in `.ts`/`.tsx` files and flags a declaration whose name and text match one already seen in another file.

Legitimate code that is NOT flagged

Duplicates within the same file, types with the same name but a different shape, non-exported types, and non-production paths are not flagged.

Evidence

Part of aislop's defensive-pattern detectors for TypeScript, scored in the maintainability tier because duplicate types create drift risk.