FRONTEND/Typescript

FRONTEND/Typescript

[TS] SetStateAction<type> useState의 set 함수타입

JS 파일로 작성된 프로젝트를 TS로 변환하던 과정에서 문제가 발생했다. 다른 변수들은 타입을 지정해줘서 문제 없이 잘 적용이 되었는데 useState의 set 함수 부분에서 빨간줄이 사라지지 않아 고뇌.. 문제상황 const [notes, setNotes] = useState([]); const sortNotes = () { let newList: noteTypes[] = []; ... setNotes(newList) // error 발생 Argument of type 'noteType[]' is not assignable to parameter of type 'SetStateAction'. Type 'noteType[]' is not assignable to type 'never[]'. Type 'n..

FRONTEND/Typescript

[TS] React 프로젝트 JS -> TS로 변환하기

Typescript Typescript는 Javascript의 변수에 형식을 지정한 파생 언어이다. Typescript로 변환하기 앞서 아래의 문서로 기본 구조를 먼저 익히자. https://yamoo9.gitbook.io/typescript/ TypeScript 가이드북 - TypeScript Guidebook 타입(Types)을 사용하면 JavaScript 애플리케이션을 개발할 때 정적 타입 검사 및 코드 리팩토링과 같은 생산성 높은 개발을 수행할 수 있습니다. 타입 설정이 필수는 아니지만, 설정할 경우 컴파일 yamoo9.gitbook.io 설치하기 https://create-react-app.dev/docs/adding-typescript/ npm install --save typescript @..

숭코기
'FRONTEND/Typescript' 카테고리의 글 목록