-
카테고리
-
세부 분야
백엔드
-
해결 여부
미해결
http-exception.filter.ts 파일 내용 중 질문이 있습니다.
21.10.08 17:45 작성 조회수 185
1
const error = exception.getResponse() as
| string
| { error: string; statusCode: number; message: string | string[] };
강의 중에 http-exception.filter.ts 파일에서 error 변수를 위와 같이 할당을 하는데 as | string 뒤에 있는 타입을 { error: string, statusCode: number; message: string | string[] };로 받는데 객체의 속성들을 특별하게 넣어준 이유가 있나요?
단순히 { error: string }로만 처리해도 다른 속성 값들이 자동으로 들어오기 때문에 출력할 때는 문제가 없는 것 같은데 정확한 타입을 제공하기 위해서 라던가 등 특별한 이유가 있는지 궁금합니다.
답변을 작성해보세요.
답변 1