Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/constants/gathering/opinion/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ export { OPINION_STEP_ORDER, OPINION_TOTAL_STEPS } from "./funnel";
export { DISTANCE_OPTIONS, DISTANCE_LABELS } from "./distance";
export { FOOD_CATEGORIES, FOOD_CATEGORY_LABELS } from "./food";
export { RANKS, RANK_LABELS } from "./rank";
export { REGION_OPTIONS } from "./region";
export { UI_TEXT } from "./ui-text";
export { MOCK_MEETING_DATA } from "./meeting";
17 changes: 17 additions & 0 deletions src/constants/gathering/opinion/region.ts
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.

이 부분은 현재 운영에 merge 할 때 conflict 날수 있음 !

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type { Region } from "#/types/gathering";

export interface RegionOption {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

추후 enum 상수로 치환할 예정이지만, 우선 작업의 단계적 접근을 위해 임시 조치

id: NonNullable<Region>;
label: string;
}

export const REGION_OPTIONS: RegionOption[] = [
{
id: "HONGDAE",
label: "홍대입구역",
},
{
id: "GANGNAM",
label: "강남역",
},
] as const;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

현재 코드에는 as const로 생성된 readonly 타입을 변경 가능한 배열 타입(RegionOption[])에 할당하려고 하여 타입 에러가 발생합니다. 또한, 스타일 가이드(규칙 4. TypeScript Rules, 196행, 224행)에서는 interface보다 type 사용을 권장하며, 상수 객체에 as const를 사용하도록 하고 있습니다.

이 상수는 타입 추론을 활용하여 더 간결하고 타입-안전하게 정의할 수 있습니다. RegionOption 인터페이스를 제거하고 as const를 통해 TypeScript가 타입을 직접 추론하도록 하는 것을 제안합니다. 이렇게 하면 불필요한 타입 정의와 import 구문을 제거하고, 스타일 가이드에 더 잘 부합하는 코드가 됩니다.

export const REGION_OPTIONS = [
	{
		id: "HONGDAE",
		label: "홍대입구역",
	},
	{
		id: "GANGNAM",
		label: "강남역",
	},
] as const;
References
  1. 스타일 가이드에서는 Props 정의에 interface보다 type을 선호한다고 명시되어 있습니다. 비록 Props가 아니더라도 일관성을 위해 type을 사용하는 것이 좋습니다. (link)
  2. 스타일 가이드에서는 상수 객체에 as const를 사용하여 타입 안정성을 높일 것을 권장합니다. 타입 추론을 활용하면 더 간결한 코드를 작성할 수 있습니다. (link)

12 changes: 8 additions & 4 deletions src/types/gathering/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,21 @@ export type FoodCategory =
export type RankKey = "first" | "second" | "third";

export interface OpinionForm {
distanceRange?: DistanceRange;
distanceRange: DistanceRange;
dislikedFoods: FoodCategory[];
preferredMenus: {
first?: FoodCategory;
second?: FoodCategory;
third?: FoodCategory;
first: FoodCategory;
second: FoodCategory;
third: FoodCategory;
};
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

스타일 가이드(규칙 4. TypeScript Rules, 196행)에서는 interface보다 type 사용을 권장하고 있습니다. OpinionFormtype으로 변경하여 프로젝트 전반의 코드 스타일 일관성을 유지하는 것을 제안합니다.

Suggested change
export interface OpinionForm {
distanceRange?: DistanceRange;
distanceRange: DistanceRange;
dislikedFoods: FoodCategory[];
preferredMenus: {
first?: FoodCategory;
second?: FoodCategory;
third?: FoodCategory;
first: FoodCategory;
second: FoodCategory;
third: FoodCategory;
};
}
export type OpinionForm = {
distanceRange: DistanceRange;
dislikedFoods: FoodCategory[];
preferredMenus: {
first: FoodCategory;
second: FoodCategory;
third: FoodCategory;
};
};
References
  1. 스타일 가이드에서는 Props 정의에 interface보다 type을 선호한다고 명시되어 있습니다. 일관성을 위해 다른 타입 정의에도 이 규칙을 적용하는 것이 좋습니다. (link)


export type OpinionStep = "intro" | "distance" | "dislike" | "preference";

/**
* @deprecated This interface will be removed in the next PR.
* Use GetGatheringResponse from #/apis/gathering instead.
*/
export interface MeetingContext {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Mock API 구현을 위해 임시로 정의했던 Interface 에 대해서 Deprecated 라벨 부착

accessKey: string;
scheduledDate: string;
Expand Down
Loading