Skip to content

レスポンス型のエイリアスを typeAliases.ts に集約#214

Open
kitsne241 wants to merge 2 commits intomainfrom
chore/aggregate-type-aliases
Open

レスポンス型のエイリアスを typeAliases.ts に集約#214
kitsne241 wants to merge 2 commits intomainfrom
chore/aggregate-type-aliases

Conversation

@kitsne241
Copy link
Copy Markdown
Collaborator

@kitsne241 kitsne241 commented Feb 14, 2026

closes #172

これまでのコードでは各コンポーネントで

import type { components } from '@/api/schema'
type Camp = components['schemas']['CampResponse']

のようなボイラープレートによって型を使用していましたが、これを typeAliases.ts に集約します

Summary by CodeRabbit

  • Refactor
    • 型定義を共通のエイリアスモジュールに集約し、複数のコンポーネント/ビューがその共通型を参照するよう切替えました。
    • 新たな共通型モジュールを導入して型の重複を削減しました。
    • 動作やUIに影響はなく、型管理・可読性・保守性が向上しています。

Copilot AI review requested due to automatic review settings February 14, 2026 09:12
@github-actions
Copy link
Copy Markdown

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 14, 2026

📝 Walkthrough

Walkthrough

複数ファイルのローカルAPIスキーマ型エイリアスを削除し、新規の src/typeAliases.ts に定義した型エイリアス群からインポートするように型参照を一括移行しました。ランタイムの挙動は変更していません。

Changes

Cohort / File(s) Summary
Central Type Aliases Module
src/typeAliases.ts
新規追加:APIスキーマ参照をまとめた14個のエクスポート型エイリアス(User, Camp, CampEvent, MomentEvent, DurationEvent, OfficialEvent, QuestionGroup, Question, Dashboard, Payment, RoomGroup, Room, RollCall, RollCallReaction)を定義。
Event Components
src/components/event/EventBlock.vue, src/components/event/EventDialog.vue, src/components/event/EventEditor.vue, src/components/event/EventEditorSettings.vue, src/components/event/EventTimePick.vue, src/components/event/ScheduleContent.vue
各コンポーネント内で定義していた DurationEvent / OfficialEvent / CampEvent 等のローカル型エイリアスを削除し、@/typeAliases から型をインポートするように置換。propsや公開署名の型参照元を移行。
Event Utilities
src/components/event/utils/eventColors.ts, src/components/event/utils/eventGrid.ts, src/components/event/utils/eventLayout.ts, src/components/event/utils/eventLib.ts
ユーティリティ内のローカルスキーマ型宣言を削除し、@/typeAliases から型をインポートするように変更。ロジックは不変。
Information / Question Components
src/components/information/AnswersDialog.vue, src/components/information/AnswersDialogContent.vue, src/components/information/QuestionEditField.vue, src/components/information/QuestionGroupEditor.vue, src/components/information/QuestionGroupPanel.vue, src/components/information/QuestionGroupViewer.vue, src/components/information/QuestionShowField.vue
QuestionGroup / Question 等のローカル型エイリアスを削除し、@/typeAliases からの型インポートへ移行。defineProps 等の型参照元を更新。
Information Components (その他)
src/components/information/PaymentInfo.vue, src/components/information/RoomInfo.vue
Payment / Room のローカル型エイリアスを削除し、@/typeAliases からインポートするように変更。
RollCall
src/components/rollcall/rollCallStream.ts, src/views/RollCallView.vue
RollCall / RollCallReaction のローカル型宣言を削除し、@/typeAliases からインポートに変更。
Store and Views
src/store.ts, src/views/RegistrationView.vue, src/views/RoomInfoView.vue, src/views/ScheduleView.vue, src/views/UserInfoView.vue
ストアとビュー内の User, Camp, CampEvent, RoomGroup, QuestionGroup 等の型参照をスキーマ直参照から @/typeAliases へ統一。ensureQueryData 等のジェネリクス型も置換。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed PR タイトルは、PR の主要な変更内容を正確に要約しており、新しい typeAliases.ts ファイルにレスポンス型のエイリアスを集約する変更を明確に示しています。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 chore/aggregate-type-aliases

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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR consolidates response type aliases from the API schema into a centralized typeAliases.ts file, eliminating repetitive boilerplate code across components. Previously, each component imported components from @/api/schema and defined local type aliases. Now, commonly used response types are exported from typeAliases.ts and imported where needed.

Changes:

  • Created src/typeAliases.ts with centralized response type aliases (User, Camp, CampEvent, QuestionGroup, Question, Dashboard, Payment, RoomGroup, Room, RollCall, RollCallReaction, and event-related types)
  • Updated 20+ files to import types from typeAliases.ts instead of defining them locally
  • Fixed QuestionGroup type usage in UserInfoView.vue to correctly specify QuestionGroup[] for the query type

Reviewed changes

Copilot reviewed 27 out of 27 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/typeAliases.ts New file with centralized response type aliases from API schema
src/views/UserInfoView.vue Replaced local type definitions with imports from typeAliases; fixed QuestionGroup array type
src/views/ScheduleView.vue Replaced local CampEvent type with import from typeAliases
src/views/RoomInfoView.vue Replaced local Room and RoomGroup types with imports from typeAliases
src/views/RollCallView.vue Replaced local RollCall type with import from typeAliases
src/views/RegistrationView.vue Replaced local Camp type with import from typeAliases
src/store.ts Replaced local User and Camp types with imports from typeAliases
src/components/rollcall/rollCallStream.ts Replaced local RollCall and RollCallReaction types with imports from typeAliases
src/components/information/*.vue Replaced local type definitions with imports from typeAliases across multiple components
src/components/event/utils/*.ts Replaced local event-related type definitions with imports from typeAliases
src/components/event/*.vue Replaced local event-related type definitions with imports from typeAliases

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 1 to +3
<script setup lang="ts">
import type { components } from '@/api/schema'
import { nextTick, ref, watch, onMounted } from 'vue'
import type { VTextField } from 'vuetify/components'

type DurationEvent = components['schemas']['DurationEventResponse']
type EventColor = DurationEvent['displayColor']

const textFieldRef = ref<VTextField>()
import type { DurationEvent } from '@/typeAliases'
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

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

The removal of the VTextField import and textFieldRef variable declaration may cause issues. The template at line 58 still references ref="textFieldRef", which suggests these declarations may have been unintentionally removed during the type alias consolidation. Consider restoring import type { VTextField } from 'vuetify/components' and const textFieldRef = ref<VTextField>(), or remove the unused ref attribute from the template if it's no longer needed.

Copilot uses AI. Check for mistakes.
@kitsne241 kitsne241 force-pushed the chore/aggregate-type-aliases branch from 42919bb to 1844832 Compare February 14, 2026 09:42
Copy link
Copy Markdown
Member

@mumumu6 mumumu6 left a comment

Choose a reason for hiding this comment

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

消し忘れっぽいところがあったので確認お願いします!

Comment on lines 6 to 7
type RollCallReactionEvent = components['schemas']['RollCallReactionEvent']
type RollCall = components['schemas']['RollCallResponse']
type RollCallReaction = components['schemas']['RollCallReactionResponse']

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ここは消し忘れですか?

Comment on lines +118 to +119
type DurationEventRequestBody = components['schemas']['DurationEventRequest']

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ここも消し忘れかな?

const isRegistered = computed(() => campStore.hasRegisteredLatest)

// 質問グループ一覧
const { data: questionGroups } = useQuery<QuestionGroup, Error>({
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ここもしかしていままでずっと型間違えてたってこと??

@kitsne241 kitsne241 assigned kitsne241 and unassigned kitsne241 Mar 2, 2026
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.

型のエイリアス定義・使用様態を改善する

3 participants