
Typescipt의 빌드 과정에서 발생하는 문제 해결 과정
Typescript를 사용하면서 다음과 같은 "The left-hand side of assignment expression may not be an optional property access" 에러가 발생했다.

해당 오류를 해석한 결과 '할당식의 왼쪽에는 Optional 연산자를 사용하면 안된다'라는 의미였다.
그래서 해당 변수가 undefined이 아니라는 확실한 조건을 추가, 즉 변수가 undefined가 아닐 때만 해당 로직을 실행하여 문제를 해결했다.
state.singlePost?.comments = action.payload;
if (state.singlePost?.comments !== undefined) {
state.singlePost.comments = action.payload;
}