Skip to content

fix: Resolve API/state type mismatch in users.ts authMecs #46

Description

@BillyOutlast

Problem

server/composables/users.ts has a @ts-expect-error suppressing a type mismatch between the API response and the shared state type.

Current state:

export const fetchUsers = async () => {
  const users = useUsers();
  const newValue = await $dropFetch("/api/v1/admin/users");
  // @ts-expect-error: API returns authMecs without `id`, but state type requires it
  users.value = newValue;
  return newValue;
};

The useUsers() state type requires authMecs entries with { id: string; mec: AuthMec }, but the /api/v1/admin/users API response intentionally omits id.

Impact

  • Every useUsers() consumer is exposed to missing runtime data
  • The @ts-expect-error hides a real incompatibility
  • Type safety is compromised for the admin users feature

Proposed Solutions

Option A (recommended): Normalize the API response by generating/assigning id during fetchUsers before storing in state.

Option B: Update the shared state type and all consumers to match the actual API payload (without id).

Option C: Update the API endpoint to include id in the response.

Context

Acceptance Criteria

  • @ts-expect-error removed from fetchUsers
  • Type check passes without suppression
  • All useUsers() consumers work correctly with the resolved type

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions