목록유니온타입 (1)
Ted's Codding study
유니온 타입과 제네릭
1. 유니온 타입여러 타입 중 하나가 될 수 있는 값을 의미function unionGeneric(value: T) { if (typeof value === 'string') { return value.toLowerCase(); } return value; // string | number}const result1 = unionGeneric('STring');const result2 = unionGeneric(1000);console.log(result1, result2); // string 1000 2. 제네릭 유틸리티 타입타입스크립트에 내장된 일련의 제네릭 타입기존 타입을 변환하거나 조작하는데 사용2-1) Partial: 모든 속성을 선택적으로 만들어줌형태: Partialinterface ..
TypeScript
2024. 7. 6. 15:05