본문 바로가기
개발일지/개발일지! error out🙅

[TS]에러해결(Argument of type '' is not assignable to parameter of type ''. Type '' is not assignable to type ''. )

by -제이리 2022. 5. 30.
728x90
320x100

타입스크립트로 변환 도중 아래 사진과 같은 오류를 만났다.

이러한 에러는 typescript가 예상하고 있는 특정한 type이 아닌, 다른 type을 넘겨줬을 때 발생하게 된다.

 

해결방법은 아래와 같이 typeof를 활용하여 정확한 javascript의 value type을 확인 하면 해결이 된다.

if (typeof token === 'string'){
validateToken(token);
}

 

728x90
320x100

댓글