Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate remaining shapes, Complete shapes migration #44

Merged
merged 14 commits into from
Mar 13, 2024

Conversation

yumincho
Copy link
Contributor

@yumincho yumincho commented Mar 12, 2024

Description

  • 공통적으로 사용되는 enum들을 관리하는 enum.tsshapes 폴더 안에 생성했습니다.
  • shapes 내 모든 파일에 대해 .tsx 확장자를 .ts 확장자로 변경하였습니다.
  • shape 파일명과 interface명을 camelCase로 작성된 파일명을 PascalCase로 변경하였습니다.
  • 아직 migrate되지 않은 shape들을 .ts 파일로 migrate하였습니다.
  • shape에서 enum이나 다른 shape을 import할 때 type만 import하도록 수정했습니다.

To-do

  • prop-types에서는 런타임에 validation을 할 수 있는 custom function을 만들어서 패스할 수 있지만, typescript에서는 interface 레벨에서의 validation이 불가능합니다. 기존 /shapes/state/timetable/LectureFocusShape.js에서 사용하던 emptyArrayShape를 대체할 validation을 component 레벨에 추가해야 합니다.

@yumincho yumincho requested a review from sboh1214 March 12, 2024 10:41
@yumincho yumincho self-assigned this Mar 12, 2024
Copy link

PR Preview Action v1.4.7
🚀 Deployed preview to https://sparcs-kaist.github.io/otlplus-web/pr-preview/pr-44/
on branch gh-pages at 2024-03-12 10:42 UTC

Copy link

[PR Preview GH Proxy (on bap)]
👍 Proxied Github Pages Preview URL to http://pr-44.otl-pr-preview.sparcsandbox.com/index.html
Proudly Powered by [email protected]

@yumincho yumincho changed the title Migration@shapes Migrate remaining shapes, Complete shapes migration Mar 12, 2024
@yumincho yumincho added the migrate migrate from JS CC to TS FC label Mar 13, 2024
@yumincho yumincho marked this pull request as draft March 13, 2024 07:52
@yumincho yumincho marked this pull request as ready for review March 13, 2024 07:55
@yumincho
Copy link
Contributor Author

Link shape이 react-router-domLink와 conflict가 나서 shape명을 추가로 변경하였습니다. (6bf160b)


export default interface TakenPlannerItem {
id: number;
item_type: 'TAKEN';
Copy link
Contributor

Choose a reason for hiding this comment

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

혹시 이 부분은 enum으로 처리하지 않은 이유가 있나요? 여러 파일들 확인해보니 현재 TAKEN, FUTURE, ARBITRARY 중 하나로 사용되고 있고 값 체크 하는 부분도 꽤 있어서요!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

오 제가 놓친 것 같습니다! 수정해서 푸시할게요 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

해결했습니다! (6084410) 나머지 코드에서 쓰이는 string들은 리팩토링 진행하면서 차차 enum으로 바꿔가면 좋을 것 같아요.

Copy link
Contributor

@sboh1214 sboh1214 left a comment

Choose a reason for hiding this comment

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

몇가지 질문들이나 제안들이 있긴 하지만, 전반적으로 좋은 것 같습니다. 수고하셨습니다 :)

@@ -0,0 +1,45 @@
export enum AdditionalTrackType {
Copy link
Contributor

Choose a reason for hiding this comment

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

이 친구는 const를 안하신 이유가 있나요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

제가 실수로 빠뜨린 것 같습니다... 😂

@@ -0,0 +1,12 @@
import type Department from '../subject/Department';
Copy link
Contributor

Choose a reason for hiding this comment

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

상대 경로 import와 절대 경로 import를 정하는 기준이 궁금합니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

앞으로는 tsconfig.json에 정의된 대로 alias를 쓸까 생각 중입니다. 슬랙 통해서 다른 분들과 논의해 보겠습니다.

"paths": {
      "@/*": ["src/*"]
    }

@@ -30,11 +31,10 @@ interface lecture {
class_title: string;
class_title_en: string;
review_total_weight: number;
professors: nestedProfessor;
professors: NestedProfessor;
Copy link
Contributor

Choose a reason for hiding this comment

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

단순한 궁금증인데, professors는 뭔가 배열이 있을거 같은데 type은 NestedProfessor 네요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

LectureShape.js 확인해본 결과 array가 맞습니다. 짚어주셔서 감사합니다. 수정하겠습니다.

@@ -0,0 +1,76 @@
import type { ItemFocusFrom } from '@/shapes/enum';

Copy link
Contributor

Choose a reason for hiding this comment

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

여기 new line 이 있는 이유가 있나요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

파일명을 변경하기 이전 파일(ItemFocusShape.js)에 newline이 있어서 그런 것 같습니다.

old_code: string;
}

interface NoneItem {
Copy link
Contributor

Choose a reason for hiding this comment

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

interface NoneItem extends ItemProtoType { ... }

이런식으로 공통 부분을 프로토타입 인터페이스로 묶어주면 좋을 것 같아요


interface FromNone {
from: ReviewsFocusFrom.NONE;
lecture?: null;
Copy link
Contributor

Choose a reason for hiding this comment

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

이 property는 null | undefined 인건가요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

어디에 사용되는지 확인해보겠습니다.

@sboh1214 sboh1214 merged commit d6c9cf7 into migration Mar 13, 2024
3 checks passed
@sboh1214 sboh1214 deleted the migration@shapes branch March 13, 2024 22:10
@yumincho yumincho mentioned this pull request Mar 14, 2024
3 tasks
@yumincho yumincho added this to the TypeScript Migration milestone Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
migrate migrate from JS CC to TS FC
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants