-
Notifications
You must be signed in to change notification settings - Fork 37
[송형진] sprint8 #318
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
[송형진] sprint8 #318
The head ref may contain hidden characters: "React-\uC1A1\uD615\uC9C4"
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
타입스크립트 적용이 주요 내용인 거 같아서 타입을 중심으로 봤습니다!
설 연휴에 수고 많으셨어요! 해피설되셔요 😍
interface PostCommentDataParams { | ||
productId?: string; | ||
editContent: string; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
타입이 꽤 많아서 따로 type.ts
에 정의해도 괜찮을 거 같아요!
</li> | ||
))} | ||
{allItemList.map( | ||
({ id, images, name, price, favoriteCount }: Product) => ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
allItemList가 Product[] 타입인 것을 위에 정의할 때에 vsCode 에게 알려줬기 때문에 여기는 따로 적을 필요 없을 거 같아요!
({ id, images, name, price, favoriteCount }: Product) => ( | |
({ id, images, name, price, favoriteCount }) => ( |
const created: number = new Date(createdAt).getTime(); | ||
const updated: number = new Date(updatedAt).getTime(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime
Date 객체의 .getTime() 메서드는 기본적으로 number 를 리턴하기에 명시해주지 않아도 될 거 같아요!
다만 잘못된 값의 경우 NaN 를 리턴하기에 이에 대한 예외처리도 있으면 좋을 거 같아요~
|
||
//omit으로 size 속성 제외 | ||
interface ItemData | ||
extends Omit<SpecificProductProps, "size" | "imageUrl" | "likeCount"> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
interface ProductItemData { | ||
id: number; | ||
imageUrl: string; | ||
name: string; | ||
price: number; | ||
likeCount: number; | ||
size: number; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SpecificProductProps 에 모두 있는 요소인 거 같은데, 물론 요소만 비슷하고, 전혀 관계없는 타입인 경우엔 상관없지만, ProductItemData 중에 특정 상품의 경우 더 많은 정보가 주어지는 경우 type SpecificProductProps = ProductItemData extends {..}
요런식으로 짜줘도 좋을 거 같아요!
요구사항
기본
심화
주요 변경사항
스크린샷
멘토에게