TypeScript5 [Typescript] Specified 'include' paths were '["**/*"]' and 'exclude' paths were '["./build"]'.ts 에러 tsconfig.json에서 Specified 'include' paths were '["**/*"]' and 'exclude' paths were '["./build"]'.ts 에러 메시지가 나타났다.에러 메시지에 명시된 것과 같이 tsconfig.json 파일에서 include와 exclude 경로를 지정해주면 된다. 나는 node 프로젝트를 진행중이라 node_modules도 exclude에 함께 명시해주었다.{ "compilerOptions": { // ... }, "include": ["**/*"], "exclude": ["./build", "node_modules"]} VSCode 사용 시에 Cmd/Ctrl + Shift + P 누른 후에 Typescript: Restart TS.. 2024. 6. 12. [TypeScript] Object literal may only specify known properties, and ''stylesheet.calendar.header'' does not exist in type 'Theme'.ts(2353) 타입스크립트 프로젝트에서 react-native-calendars 패키지를 사용하여 Calendar 컴포넌트 내에 theme props에 'style.calendar.header' 선언 시 아래 에러가 발생하는 것을 확인하였다.Object literal may only specify known properties,and ''stylesheet.calendar.header'' does not exist in type 'Theme'.ts(2353)index.d.ts(8, 5): The expected type comes from property 'theme' which isdeclared here on type 'IntrinsicAttributes & Pick & Pick & Pick' 이런 경우에는 as.. 2024. 5. 28. [TypeScript] 에러: Cannot invoke an object which is possibly 'undefined'.ts(2722) 아래처럼 타입을 선언한 후에 함수를 호출할 때 Cannot invoke an object which is possibly 'undefined'.ts(2722)라는 메시지를 받았다.type OwnProps = { onPopupFocus?: () => void; onPopupDefocus?: () => void;};const togglePopupVisible = () => { if (isPopupVisible) onPopupDefocus(); else onPopupFocus();}; 이것은 onPopupFocus와 onPopupDefocusf라는 함수의 타입을 선언할 때 onPopupFocus?와 같이 물음표를 함께 적어 필수로 선언되지 않아도 되는 값이라고 정의했기 때문이다. 정의되지 않은 .. 2024. 5. 27. [TypeScript] styled-components 사용 시 Unknown property: 'elevation' ts-styled-plugin(9999) 경고 Typescript 프로젝트에서 styled-components를 사용하여 elevation 속성을 사용할 때 노란 언더라인으로 아래 경고가 나타나는 것을 확인하였다. 프로젝트를 작동시키는데에는 문제가 없지만 파일명과 코드 상에 노란색으로 표시되는 것이 거슬리므로 제거해보도록 하자.Unknown property: 'elevation' ts-styled-plugin(9999) 1. 라이브러리 설치npm install -D @styled/typescript-styled-plugin 2. tsconfig.json 수정compilerOptions > plugins 부분에 새로 추가한 라이브러리와 elevation 속성에 대한 내용을 추가해준다.{ "compilerOptions": { "plugins": .. 2024. 5. 22. [TypeScript] TypeScript에서 new Date() 사용하기 디데이를 계산하는 함수를 작성하는 도중에 3번째 줄에서 타입스크립트 에러가 발생하였다.const targetDay = new Date(date);const today = new Date(Date.now() + KOREA_TIME_DIFFERENCE);const dayGapMillis = today - targetDay; // today와 targetDay에 붉은선이 생겼다.const dayGap = Math.floor(dayGapMillis / ONE_DAY_MILLISECONDS);today와 targetDay를 뺄셈하는 도중에 발생한 에러 내용은 다음과 같다: The left-hand side of an arithmetic operation must be of type 'any', 'number', .. 2024. 5. 21. 이전 1 다음 반응형