728x90
로그아웃 기능을 만들던 중 에러가 발생했다.
...
logout(null); <-- Error
Error: null' 형식의 인수는 'string | undefined' 형식의 매개 변수에 할당될 수 없습니다
타입스크립트를 쓴 지 얼마 안 돼서 해결하기가 참 난감했다.
가장 쉬운 해결방법은 tsconfig.json 파일에 들어가서 "strictNullChecks": false를 넣어주면 된다.
null, undefined를 항상 서브 타입으로 할당 가능하게 해준다고 한다.
... tsconfig.json
"compilerOptions": {
...
"strictNullChecks": false,
}
구글은 신이야!
728x90
'기록장 > 에러 모음' 카테고리의 다른 글
[JS error] SyntaxError: Cannot use import statement outside a module (1) | 2023.11.22 |
---|---|
[React error] [Profile] is not a <Route> component. react-router-dom 에러 (1) | 2023.07.02 |
[React Native] TypeError: undefined is not an object... (0) | 2022.06.16 |
React를 쓰다가 생긴 No overload matches this call error in TypeScript (1) | 2022.05.16 |
Apollo client 사용 중 400 (Bad request) error (0) | 2022.04.27 |
댓글