본문 바로가기

typescript3

[Typescript] Property 'includes' does not exist on type 'string[]'. ts(2339) includes 에러가 났다. 오류 원인: includes 문법은 ES7 (ES2016)부터 지원된다. 버전을 es2017로 높여주자. 아래와 같이 es2017 문법을 추가하자. 2021. 6. 1.
[Typescript ]Property 'innerText' does not exist on type 'EventTarget'.ts(2339) 이벤트 위임을 구현하면서 target에 접근하면서 발생했다. digitClickEvent는 eventListener의 callback 이다. const digitClickEvent = (e: Event): void => { console.log(e.target.innerText); }; 타입스크립트가 적절한 타입을 찾지 못해서 발생하는 오류이다. 타입스크립트에게 명시적 형변환을 해주자. const digitClickEvent = (e: Event): void => { const eventTarget = e.target as HTMLElement; console.log(eventTarget.innerText); }; https://stackoverflow.com/questions/54886637/error.. 2021. 6. 1.
[Typescript] cannot be compiled under '--isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export {}' statement to make it a module. 타입스크립트 1일차 다음과 같은 오류를 만났다. 코드는 한줄밖에없는데 무엇이 문제일까..? src/js/index.ts:1:1 - error TS1208: 'index.ts' cannot be compiled under '--isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export {}' statement to make it a module. const i = 'holee'; console.log(i); > javascript-calculator@1.0.0 check-types > tsc src/js/index.ts:1:1 - error TS1208: 'index.ts' .. 2021. 5. 21.