Skip to content

chore: Fix type errors (#2657)#2733

Merged
KATO-Hiro merged 2 commits intostagingfrom
#2657
Oct 22, 2025
Merged

chore: Fix type errors (#2657)#2733
KATO-Hiro merged 2 commits intostagingfrom
#2657

Conversation

@KATO-Hiro
Copy link
Collaborator

@KATO-Hiro KATO-Hiro commented Oct 22, 2025

close #2657

型エラーの修正が本PRの本体です。

Summary by CodeRabbit

  • Documentation

    • Added developer guidance on TypeScript 5.9 type inference, utilities for precise typing, and practical examples and lessons.
  • Improvements

    • Strengthened type safety in database seeding utilities with explicit parameter types and return-type usage.
    • Normalized task grade handling to ensure consistent grade values during seeding.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 22, 2025

Walkthrough

Adds explicit type annotations to internal seed helper functions in prisma/seed.ts to satisfy TypeScript 5.9 type inference, and adds a new developer note documenting the inference approach, utility types used, examples, and lessons learned.

Changes

Cohort / File(s) Summary
Documentation
docs/dev-notes/2025-10-22/fix-type-errors/plan.md
New documentation describing TypeScript 5.9 type inference considerations, explanation of used utilities (e.g., extracting element type via (typeof X)[number], ReturnType<typeof fn>), updated function signature examples, Q&A, and lessons learned.
Seed Function Type Refactoring
prisma/seed.ts
Internal seed helper functions (addUser, addTask, addWorkBook, addTag, addTaskTag, addSubmissionStatus, addAnswer) updated to accept strongly typed parameters derived from data arrays ((typeof ...)[number]) and factory return types (ReturnType<typeof define...Factory>). Imported getTaskGrade and used it to coerce task.grade when creating tasks. All internal invocations updated accordingly; no public APIs changed.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 Tip-tap, I nibble at the line,
Tip types in rows now all align,
Tuples snug and factories neat,
Seeded fields are tidy, sweet.
I hop away — the types feel fine.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 23.08% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "chore: Fix type errors (#2657)" accurately summarizes the main objective of the changeset, which is to resolve TypeScript 5.9 type checking errors in the codebase by adding proper type annotations to function parameters in prisma/seed.ts. The title is concise, clear, and specific enough that a developer scanning the history would immediately understand the primary purpose of the change without being vague or overly broad.
Linked Issues Check ✅ Passed The code changes directly fulfill the objective of issue #2657 to fix TypeScript 5.9 type checking errors. The prisma/seed.ts modifications implement proper type annotations using TypeScript utilities such as array element type extraction and ReturnType utilities across all affected functions (addUser, addTask, addWorkBook, addTag, addTaskTag, addSubmissionStatus, addAnswer), and the addition of the getTaskGrade import resolves type issues related to the grade property. The accompanying documentation explains the type inference approach and concepts used to implement these fixes, supporting the overall goal of eliminating development-time type checking noise.
Out of Scope Changes Check ✅ Passed All changes in the pull request are directly aligned with the stated objective of fixing TypeScript type checking errors. The code modifications in prisma/seed.ts add precise type annotations to function parameters and resolve type issues related to the grade property, while the new documentation file (plan.md) explains the type inference concepts and implementation details supporting these fixes. No extraneous changes unrelated to the type error resolution objective are present in the changeset.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch #2657

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between e7ba3fa and 52328fe.

📒 Files selected for processing (2)
  • docs/dev-notes/2025-10-22/fix-type-errors/plan.md (1 hunks)
  • prisma/seed.ts (8 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: preview
🔇 Additional comments (9)
docs/dev-notes/2025-10-22/fix-type-errors/plan.md (1)

1-76: LGTM! Excellent documentation of the type inference approach.

The documentation clearly explains the TypeScript type operations used to resolve the type checking errors. The Q&A format effectively breaks down complex concepts like indexed access types and ReturnType, and the implementation examples align perfectly with the actual changes in seed.ts.

prisma/seed.ts (8)

23-23: LGTM! Proper use of type-only import.

Using the type keyword for imports ensures this is stripped during compilation and doesn't impact the runtime bundle.


109-114: LGTM! Type annotations correctly resolve TypeScript 5.9 strict checking.

The function parameters now have explicit types using indexed access types for array elements and ReturnType for factory parameters, eliminating implicit any types.


160-163: LGTM! Consistent type annotation pattern.

The function parameters follow the same type annotation approach as other seed helper functions.


236-239: LGTM! Type annotations correctly applied.

The function parameters use the same consistent type annotation pattern.


309-309: LGTM! Type annotations are correct.

The function parameters have proper type annotations. The single-line format is acceptable given the brevity of the parameters.


369-372: LGTM! Type annotations correctly applied.

The function parameters follow the established type annotation pattern.


417-420: LGTM! Type annotations correctly applied.

The function parameters use the consistent type annotation approach.


482-485: LGTM! Type annotations correctly applied.

The function parameters follow the established type annotation pattern, completing the consistent refactoring of all seed helper functions.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
prisma/seed.ts (1)

171-171: Remove unnecessary as string type assertion.

The task.grade property is already typed as string from the object literals in prisma/tasks.ts (e.g., grade: 'Q8', grade: 'D3'). TypeScript correctly infers this type, making the as string assertion redundant.

Line 171:

    grade: getTaskGrade(task.grade),
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 52328fe and 7942e72.

📒 Files selected for processing (1)
  • prisma/seed.ts (8 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: preview
🔇 Additional comments (2)
prisma/seed.ts (2)

23-23: LGTM! Import supports grade validation.

The import of getTaskGrade is appropriate and necessary for the safe grade conversion used in addTask.


109-114: Excellent type annotations using TypeScript utility types.

The explicit parameter types using (typeof array)[number] and ReturnType<typeof fn> are idiomatic TypeScript patterns that provide strong type safety without duplicating type definitions. This approach correctly addresses TypeScript 5.9's stricter type inference requirements.

Also applies to: 160-163, 236-239, 309-309, 369-372, 417-420, 482-485

Copy link
Collaborator Author

@KATO-Hiro KATO-Hiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@KATO-Hiro KATO-Hiro merged commit 5339224 into staging Oct 22, 2025
3 checks passed
@KATO-Hiro KATO-Hiro deleted the #2657 branch October 22, 2025 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] 型チェックでエラーが発生している箇所を修正しましょう

1 participant

Comments