728x90
반응형
이 무슨 귀신 씨나락 까묵는 소린가 싶어 구글 검색을 했고,
아래 글을 발견함. 읽어볼것.
아래 코드는 유용한 기능 같다.
type EventType = "mouseout" | "mouseover" | "click"
function handleEvent(event: EventType) {}
handleEvent("click")
handleEvent("hover") // compile error: Argument of type '"hover"' is not assignable to parameter of type 'EventType'.
https://soopdop.github.io/2020/12/01/index-signatures-in-typescript/
728x90
반응형
'IT > TypeScript' 카테고리의 다른 글
고차함수 (high-order function) 다른 함수를 반환하는 함수 (0) | 2022.10.26 |
---|---|
클로저(closure) - 유효범위 의미 (0) | 2022.10.26 |
잔여 연산자(rest operator)와 전개 연산자(spread operator) (0) | 2022.10.21 |
접근 제한자(access modifier) 와 생성자(constructor), 클래스,인터페이스 (0) | 2022.10.20 |
타입주석(type annotation), 타입추론(type inference), 선택속성(optional property), 템플릿 문자열(template string) (0) | 2022.10.19 |
댓글