[TS] TypeScript exercises 11

Chobby·2023년 3월 23일
1

TS

목록 보기
5/6

타입이 선언되지 않은 라이브러리를 사용할 때, 어떻게 사용이 가능한가를 물어보는 문제이다.

우선, index.d.ts 파일에 declarestr-utils의 타입을 재정의하는 부분을 수정한다.

declare module 'str-utils' {
    type StrUtils = {
        (value: string): string
    }

    export const strReverse: StrUtils
    export const strToLower: StrUtils
    export const strToUpper: StrUtils
    export const strRevestrToUpperrse: StrUtils
    export const strRandomize: StrUtils
    export const strInvertCase: StrUtils

}

value라는 파라미터를 받아, string을 반환하는 함수들이며 export const의 구조로 선언하여 재정의한다.

profile
내 지식을 공유할 수 있는 대담함

0개의 댓글