Skip to content

Optional type-identifier-aware normalization to split structurally identical DTOs #21

Description

@Dominik-O22

Problem

TypeScriptNormalizer.isName (src/TypeScriptNormalizer.ts L37) plus keepsStructuralChild (L33) strip all identifiers, so two unrelated DTOs/value objects with the same shape but different field/type names match. This is the correct default — it's what lets the tool catch copy-paste-then-rename duplicates — but it's a frequent false-positive source for distinct domain types that merely share a shape (e.g. { id: OrderId; total: Money } vs { id: SkuId; total: Count }).

Proposed change

Add an optional, off-by-default normalization mode that retains type-position identifiers as structural markers:

  • In TypeScriptNormalizer, when the mode is on, keep TypeReference typeName identifiers (and optionally property names) instead of dropping them in keepsStructuralChild/isName, emitting them as markers via the existing markers() mechanism so they participate in the fingerprint.
  • Thread a typeAwareNormalization flag through OptionsFileScannerTypeScriptNormalizer (the normalizer is constructed in FileScanner).
  • CLI: --type-aware (or similar) in Options.parse.

This makes {a: Foo; b: Bar} and {a: Baz; b: Qux} diverge while leaving the name-blind default intact.

Acceptance

  • With the flag on, two same-shaped/different-typed interfaces drop below threshold.
  • With it off, behavior is byte-for-byte unchanged (fingerprints identical to today).

Related

Pairs with the kind-diversity floor; both target structurally-identical-but-semantically-distinct type declarations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions