-
Argument of type '{ a: A; }' is not assignable to parameter of type 'DeepPartial<"entity">[]'.언어/Javascript 2023. 8. 17. 11:12
.save()를 할경우 구조분해할당으로 값을 넘겨줬었다.
근데 구조분해할당은 값을 덮어씌우지 않는이상 불필요하다는 피드백을 들어서 ... 만 빼줬다.
근데 위와 같은 에러가 났다.
원래모습 (데이터 잘 들어감)
createLectureInfoService({ createLectureInfoInput, }: ILectureInfoCreateInput) { const result = this.lectureInfoRepository.save({...createLectureInfoInput}); return result; }...만 뺀 모습 (Argument of type '{ a: A; }' is not assignable to parameter of type 'DeepPartial<"entity">[]'. 에러남)
createLectureInfoService({ createLectureInfoInput, }: ILectureInfoCreateInput) { const result = this.lectureInfoRepository.save({createLectureInfoInput}); return result; }수정
createLectureInfoService({ createLectureInfoInput, }: ILectureInfoCreateInput) { const result = this.lectureInfoRepository.save(createLectureInfoInput); return result; }객체 안에 객체가 들어간 형태이기 때문에 오류가 나는것 같다. 해당 키 값은없으니까.
구조분해할당 / 레스트 파라미터 헷갈릴때 개념 잡기 좋은 블로그
JavaScript의 구조 분해 할당(Destructuring Assignment) 활용하기
자바스크립트에서 가장 유용하고도 많이 쓰이는 문법이라 하면 구조 분해 할당을 빼놓을 수 없다고 생각합니다.
chanhuiseok.github.io
반응형'언어 > Javascript' 카테고리의 다른 글
[NodeJS] Error [ERR_REQUIRE_ESM]: require() of ES Module ~ from ~ not supported. 에러 (0) 2023.08.23 typeorm repository.delete 삭제 안될 때 (0) 2023.08.22 [NestJS] 네스트 JS Controller 데코레이터 정리 (0) 2023.08.16 typescript 에러 | Nest can't resolve dependencies of the "Service" (0) 2023.08.04 [자바스크립트]정규표현식 (0) 2023.07.26