Skip to content

Deduplicate Window.allCards inline type to reference CardInfo from types.ts #411

@arasaka-net

Description

@arasaka-net

The Window.allCards property in global.d.ts defines its element type inline, duplicating the CardInfo interface already declared in types.ts. Using an import reference eliminates the duplication and ensures changes to CardInfo propagate automatically.

Context
The global.d.ts file declares Window.allCards with an inline object type that has the same shape as the CardInfo interface in src/scripts/types.ts — both have title, side_code, faction_code, type_code, image, and optional code fields. If a field is added or narrowed in CardInfo (e.g., issue #295 proposes narrowing side_code to a literal union), the Window declaration must be updated separately or the two definitions drift apart silently. TypeScript declaration files support import() type references, so allCards can be typed as import('./scripts/types.ts').CardInfo[] without introducing a runtime import.

Affected Files

  • src/global.d.ts:53 — Replace the inline { title: string; side_code: string; ... }[] type for allCards with import('./scripts/types.ts').CardInfo[]

Requirements

  • Window.allCards is typed as import('./scripts/types.ts').CardInfo[] instead of an inline object type
  • The inline type literal for allCards is fully removed — no residual duplicate
  • npm run typecheck passes with no new errors
  • No runtime behavior changes

Verification

  • npm run typecheck
  • grep -n 'allCards' src/global.d.ts

Not In Scope

Evidence

  • src/global.d.ts:52-60allCards is typed as { title: string; side_code: string; faction_code: string; type_code: string; image: string; code?: string; }[] — an inline copy of the CardInfo interface
  • src/scripts/types.ts:18-25CardInfo interface has identical fields: title: string, side_code: string, faction_code: string, type_code: string, image: string, code?: string

Arasaka Queue Planning Division.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions