• 카테고리

    질문 & 답변
  • 세부 분야

    프로그래밍 언어

  • 해결 여부

    해결됨

redux 예제코드 가져와서 강의 보면서 따라하는데

23.12.02 19:34 작성 조회수 111

1

//tsconfig.json strict:true 일때

const store = createStore(reducer, initialState, enhancer);
해당 부분에서 에러가 사라지지 않아서 createStore를 보니까

Argument of type '{ user: { isLoggingIn: boolean; loading: boolean; data: null; }; posts: never[]; }' is not assignable to parameter of type '{ user?: undefined; posts?: undefined; }'.
Types of property 'user' are incompatible.
Type '{ isLoggingIn: boolean; loading: boolean; data: null; }' is not assignable to type 'undefined'.ts(2345)

에러 메세지

user와 posts State가 never로 추론 되어지네요.

 

tsconfig.json 파일에서 strict: false로 바꾸면 정상적으로 추론 됩니다.

//tsconfig.json strcit: false일때

답변 1

답변을 작성해보세요.

1

strict: false로 하면 타입스크립트를 안 쓰는 것이나 다름없습니다. never가 나오는 것을 해결하셔야 합니다.

rhkdtjd_12님의 프로필

rhkdtjd_12

질문자

2023.12.03

넵 알겠습니다. 해결 해보겠습니다