Object literal may only specify known properties

이유정·2023년 9월 2일
1

Typescript

목록 보기
3/5

현재 에러 상황


여기서 핵심은,
'Object literal may only specify known properties, and 'hourDigital' does not exist in type ~~' 이 문장이다.

Object literal may only specify known properties

객체 리터럴

객체

  • 자바스크립트는 객체 기반 프로그래밍 언어다.
  • 원시 값을 제외한 나머지 값은 모두 객체이다.
  • 객체는 0개 이상의 프로퍼티로 구성된 집합이다.
  • 프로퍼티는 keyvalue로 구성된다.
  • 프로퍼티 값이 함수라면 method라 부른다.

객체 리터럴

  • 리터럴: 문자나 약속된 기호를 사용한 표기법이다.
  • 객체를 생성할 때 사용하는 방법이다.
  • 객체 리터럴의 중괄호는 코드 블록을 의미하는 것이 아니라 값으로 평가되기 때문에 닫는 괄호 뒤에는 세미콜론(;)을 붙인다.

참고

https://bobbyhadz.com/blog/typescript-object-literal-may-only-specify-known-properties

이 사이트에 들어가서 이 부분을 읽어봐라. !

Object literal may only specify known properties in TS

The "Object literal may only specify known properties" error occurs when a property in an object literal doesn't exist in the object's type.

To solve the error, make sure to type all of the object's properties and fix spelling errors in property names if you have any.

Here is an example of how the error occurs.

insight

Object literal may only specify known properties
이 에러는 모든 타입을 다 써주라는 뜻이다.

그래서 타입을 이렇게 써줬다!!!

그러니까 결국,
hourDigital 만의 문제는 아니였다.

profile
강의 기록 블로그

0개의 댓글

관련 채용 정보