HTML 조작

    [코딩애플] 타입스크립트 HTML 조작시 주의점 (1)

    우선.. { "compilerOptions": { ... "strictNullChecks": true, ... }, } tsconfig.json 파일에서 strictNullCheck 옵션을 true로 바꾼다. (혹은 "strict" : true로 써둬도 된다) 이렇게 설정하면 TypeScript 컴파일러는 더 엄격한 규칙을 적용하며, 변수에 대한 null 체크가 강제된다. HTML 조작시 오류 let title = document.querySelector('#title'); title.innerHTML = '안녕하세요'; // title is possibly Element | null TypeScript에서 strictNullChecks 옵션이 활성화된 경우, 위 메서드의 반환 타입은 Element | ..