Skip to content

G.1 — Replace : any in useAdmin.ts with Prisma types #316

@v-patel

Description

@v-patel

G.1 — Replace : any in useAdmin.ts with Prisma types

What's wrong

app/composables/useAdmin.ts has ~18 : any annotations. That means the entire admin composable has zero type-checking — a typo on a field name doesn't fail typecheck, it fails at runtime in the user's browser.

How to fix

Prisma generates types under prisma/generated/client. Import them:

import type { Form, FormComponent, FormGroup, Announcement, Student } from '~~/prisma/generated/client'

Replace each : any:

  • (question: any)(question: FormComponent)
  • useState<any[]>('questions', ...)useState<FormComponent[]>('questions', ...)
  • useState<any[]>('announcements', ...)useState<Announcement[]>('announcements', ...)
  • useState<any[]>('publishedForms', ...)useState<Form[]>('publishedForms', ...)
  • etc.

For the API call helpers, define a small response type that matches what the server returns:

type FormApiCreateForm = {
  success: boolean
  message: string
  data: Form & { questions: FormComponent[] }
}

Files

  • app/composables/useAdmin.ts

Severity

M.

Acceptance

  • No : any annotations remain in useAdmin.ts.
  • pnpm typecheck passes (after E.2 lands).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions