Challenge
아래 Repository 는 다양한 Typescript Challange 를 가지고 있습니다. 해당 도전과제를 풀어보며 타입스크립트 실력을 키워보세요!
Return Type Challenge
지금까지 배웠던 지식으로 내장 제네릭 ReturnType<T>
를 사용하지 않 고 함수의 Return 타입을 추출하는 'MyReturnType'을 작성해보세요.
const fn = (v: boolean) => {
if (v)
return 1
else
return 2
}
type a = MyReturnType<typeof fn> // should be "1 | 2"