본문 바로가기
728x90
반응형

IT/TypeScript12

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ name: string; age: number; }'. 이 무슨 귀신 씨나락 까묵는 소린가 싶어 구글 검색을 했고, 아래 글을 발견함. 읽어볼것. 아래 코드는 유용한 기능 같다. 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/ TypeScript에서 string key로 객체.. 2022. 10. 28.
고차함수 (high-order function) 다른 함수를 반환하는 함수 https://yangheat.tistory.com/58?category=905031 [TypeScript] 고차함수(high-order function) 2021.07.10 - [TypeScript] - [TypeScript] 커리(curry) - 함수에 가로 여러개 사용하는 경우 고차 함수란 어떤 함수가 또 다른 함수를 반환할 때 고차 함수라고 합니다. 1차 함수 함수가 아닌 단순히 값은 반환 yangheat.tistory.com 2022. 10. 26.
클로저(closure) - 유효범위 의미 https://yangheat.tistory.com/60 [TypeScript] 클로저(closure) - 유효 범위 클로저 클로저는 지속되는 유효 범위(persistence scope)를 의미합니다. const add = (x: number) => { // 바깥쪽 유효 범위 시작 return (y:number): number => { // 안쪽 유효 범위 시작 return x + y; // 클로.. yangheat.tistory.com 2022. 10. 26.
잔여 연산자(rest operator)와 전개 연산자(spread operator) 연산자 기호 : ... (점 3개) 연산자의 위치에 따라 잔여 연산자(왼쪽, 대입 받는쪽), 전개 연산자(오른쪽, 개체의 개별 속성을 전개해 대입하는쪽)라고 함. rest operator 예) --------------------------------------------------------------------------------------------- let address: any = { country: 'Korea', city: 'Seoul', address1: 'Gangnam-gu', address2: 'Sinsa-dong 123-456', address3: '789 street, 2 Floor ABC building' } const {country, city, ...detail} = addr.. 2022. 10. 21.
728x90
반응형