인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

Inflearn Community Q&A

rhkdtjd_12's profile image
rhkdtjd_12

asked

[Renewal] TypeScript All-in-One: Part 2. Practical Analysis

Typing thunk middleware

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

Resolved

Written on

·

194

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일때

typescript

Answer 1

1

zerocho님의 프로필 이미지
zerocho
Instructor

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

rhkdtjd_12님의 프로필 이미지
rhkdtjd_12
Questioner

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

rhkdtjd_12's profile image
rhkdtjd_12

asked

Ask a question