Skip to content

Latest commit

 

History

History
38 lines (24 loc) · 1.36 KB

File metadata and controls

38 lines (24 loc) · 1.36 KB

Example Output: TypeScript Review (Next.js)

Typical AI response when using prompts/code-quality/typescript.md on a PR with component and API changes.


components/UserCard.tsx

  • Line 12user is implicitly any because getUser() has no return type. Fix: Define type User = { id: string; name: string; avatar?: string } and type the return as getUser(): Promise<User>.

  • Line 18onClick prop is untyped in the component's props. Fix: Add onClick?: () => void to the props interface.

app/api/users/route.ts

  • Line 5searchParams is used as a generic object; get('q') returns string | null. Fix: Narrow with const q = searchParams.get('q') ?? '' or extract from typed NextRequest.

  • Line 22 — Response returns any because fetchUsers() is untyped. Fix: Type the return as fetchUsers(): Promise<User[]> and use it in Response.json().

lib/auth.ts

  • Line 8session allows undefined but is used without a guard. Fix: Add if (!session) return null before accessing session properties.

Summary

File Issues
UserCard.tsx 2 (implicit any, untyped props)
api/users/route.ts 2 (searchParams, untyped return)
lib/auth.ts 1 (nullable session)

Total: 5. Prioritize typing getUser/fetchUsers and the UserCard props.