타입스크립트는 타입이 없는 javascript와 함께 쓰기때문에 불가피하게 사용해야 할 경우가 있음
리턴값이나 변수의 타입에 대해 100프로 확신하는 경우에만 사용해야함
const result = jsStrFunc();
console.log((result as string).length);
console.log((<string>result).length);
const button = document.querySelector('class')!;
'Type script' 카테고리의 다른 글
객체지향의 4가지 원칙 (0) | 2021.04.18 |
---|---|
OOP 객체지향프로그래밍이란 ? (0) | 2021.04.18 |
타입추론 type inference (0) | 2021.04.17 |
Enum Type (0) | 2021.04.17 |
Intersection Type (0) | 2021.04.15 |
댓글