Skip to content

Remove stale as any casts and outdated comment in factory.ts #129

@Sam-Bolling

Description

@Sam-Bolling

Task

Remove the unnecessary as any casts on factory.ts lines 43–47 and the outdated comment that claims root and getCollectionDocument are "currently private." Task 6 (Issue #122) already made them public.

Finding Reference: F-NEW-01 from final-project-code-review.md
Severity: Minor (BUG)
Category: Type error / stale code
Implementation Branch: phase-6


Problem Statement

factory.ts lines 43–47 contain:

// Access root and getCollectionDocument via `any` because they are
// currently `private`. Task 6 (Issue #122) changes them to `public`;
// these casts will be removed then.
const ep = endpoint as any;

Issue #122 (Task 6) is complete. root is public get at endpoint.ts:67. getCollectionDocument is public at endpoint.ts:357. The as any cast:

  1. Bypasses TypeScript's type system for no reason — loses all type checking on ep.getCollectionDocument() and ep.root
  2. Has a misleading comment that looks like an unresolved TODO
  3. Would confuse upstream reviewers who see as any and ask "why?"

Evidence:

// endpoint.ts line 67:
public get root(): Promise<OgcApiDocument> {

// endpoint.ts line 357:
public getCollectionDocument(collectionId: string): Promise<OgcApiDocument> {

Impact: No functional impact — code works identically. But the as any undermines type safety and the stale comment is misleading. This is on the clean-pr branch pushed to upstream PR #136.

Files to Create or Modify

File Action Est. Lines Purpose
src/ogc-api/csapi/factory.ts Modify ~5 changed Remove as any cast, access endpoint.root and endpoint.getCollectionDocument() directly, delete stale comment

Proposed Fix

Remove the as any cast and access the public methods directly:

// Before:
const ep = endpoint as any;
const collectionDoc = await ep.getCollectionDocument(collectionId);
const rootDoc = await ep.root;

// After:
const collectionDoc = await endpoint.getCollectionDocument(collectionId);
const rootDoc = await endpoint.root;

Delete the 3-line comment above the old cast.

Scope — What NOT to Touch

  • ❌ Do NOT modify endpoint.ts — the visibility change is already complete (Issue P6 Task 6: Modify endpoint.ts — Remove CSAPI Coupling #122)
  • ❌ Do NOT modify index.ts (barrel file)
  • ❌ Do NOT modify any test files in this issue
  • ❌ Do NOT modify any other files outside factory.ts
  • ❌ Do NOT change any CSAPI business logic

Acceptance Criteria

  • as any cast removed from factory.ts
  • Stale comment about "currently private" removed
  • endpoint.root and endpoint.getCollectionDocument() accessed directly
  • npx tsc --noEmit passes (typecheck clean)
  • npm run lint passes
  • npm run test:node passes
  • npx prettier --check src/ogc-api/csapi/factory.ts passes

Dependencies

Blocked by: Nothing (Issue #122 already made the methods public)
Blocks: Nothing


Operational Constraints

⚠️ MANDATORY: Before starting work on this issue, review docs/governance/AI_OPERATIONAL_CONSTRAINTS.md and the P6 Implementation Guide.

Key constraints:

  • Precedence: OGC specifications → AI Collaboration Agreement → This issue description → Existing code → Conversational context
  • No scope expansion: Fix the finding, nothing more
  • Minimal diffs: Prefer the smallest change that satisfies the acceptance criteria
  • Zero business logic changes: Phase 6 touches the integration boundary only
  • Verify against the 12 gates: The acceptance criteria should reference specific verification gates from the Contribution Goal

References

# Document What It Provides
1 final-project-code-review.md §9 F-NEW-01 Evidence and context
2 findings-effort-assessment.md Effort estimate (1 pass)
3 src/ogc-api/csapi/factory.ts lines 43–47 Code to modify
4 src/ogc-api/endpoint.ts lines 67, 357 Proof that methods are already public

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingphase-6

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions