React “Type annotations can only be used in TypeScript files." 오류

개발새발·2023년 1월 1일

react

목록 보기
1/3

React 공부를 하다가 제목과 같이 “Type annotations can only~” 어쩌구 오류라는 오류를 발견했다.

오류내용

“Type annotations can only be used in TypeScript files.”
Type annotation()은 타입스크립트파일(.ts)에서만 사용할 수 있다는 오류였다.


오류해결

: Vscode에서 TypeScript and JavaScript Language Features 라는 기능이 켜져있어서 그렇다고 한다. 그래서 여기 나온 답변을 보고 아래와 같이 따라했다.

  1. 플러그인 에서 TypeScript and JavaScript Language Features 를 검색한다.
  1. 사진과 같은 플로그인이 뜨고 Disable 이라는 버튼을 클릭한다.

  2. 사진과 같이 Reload Required 라는 버튼으로 바뀌고 클릭하여 Vscode 를 다시연다.

  3. 사진과 같이 오류가 사라졌다.

profile
발새발개

0개의 댓글