[김승석] Sprint10#311
Hidden character warning
Conversation
| * 질문하기 | ||
| * Comment 인터페이스의 타입을 전부 사용안했는데 오류가 나지않는 이유?? | ||
| * 예를 들어 createdAt는 ?. 처럼 선택적이 아니지만 오류가 안남 | ||
| */ |
There was a problem hiding this comment.
타입스크립트 관련해서 질문있습니다.
Comment 인터페이스의 타입을 전부 사용안했는데 오류가 나지않는 이유가 뭘까요?
There was a problem hiding this comment.
TypeScript는 타입을 선언하는 것만으로는 오류를 발생시키지 않습니다.
즉, 타입이 정의되어 있지만 사용되지 않았다고 해서 TypeScript가 이를 강제하지는 않습니다.
| data, | ||
| comment, | ||
| }: InferGetServerSidePropsType<typeof getServerSideProps>) { | ||
| // null 일수도 있어서 예외처리를 해줘야 아래 data 사용 시 ?. 처리 안해줘도 됨. |
There was a problem hiding this comment.
null 관련해서 tsconfig.ts에
"strictNullChecks": false, 이 옵션 사용해봐도 괜찮을까요?
아직 사용은 안했습니다
There was a problem hiding this comment.
strictNullChecks는 켜두는게 좋을것 같습니다!
무조건 필수인건 아니지만 좋은 습관을 위해선 필수라고 생각합니다
| <img | ||
| src={ | ||
| props.writer.image | ||
| ? props.writer.image | ||
| : "/assets/img/icon_my.svg" | ||
| } | ||
| alt={props.writer.nickname} | ||
| /> |
There was a problem hiding this comment.
src에 조건문을 넣기보단 src가 달라짐에따라 img 태그자체를 조건부 랜더링하는게 더 괜찮아보이네요
There was a problem hiding this comment.
이 컴포넌트는 결국 input을 고스란히 반환할 뿐인 스타일컴포넌트군요 props의 확장성을 좀더 고민해보시면 좋겠네요
| const ref = useOutsideClick(() => { | ||
| setMenu(false); | ||
| }); |
|
|
||
| const fetchComments = async ( | ||
| id: number | ||
| ): Promise<CommentListResponse | null> => { |
There was a problem hiding this comment.
Promise의 제네릭 에는 resolve 함수의 반환타입을 명시해주면 됩니다. 해당 api가 null도 명시적으로 반환하나요?
| const [title, setTitle] = useState(""); | ||
| const [content, setContent] = useState(""); |
There was a problem hiding this comment.
이 두개의 상태는 하나로 묶을 수 있을것 같군요
| * Promise.all을 활용해서 병렬로 처리해서 시간을 단축시킴. | ||
| * 구조분해문법 사용해서 좀 더 깔끔하게 처리 | ||
| */ | ||
| const [bestResponse, commonResponse] = await Promise.all([ |
요구사항
기본
심화
멘토에게