
그지같은 설명을 가진 문제였다.
t만큼의 시간 후 args를 인자로 실행되는 함수 t를 정의함cancelFn의 이름의 취소 함수를 반환함type JSONValue = null | boolean | number | string | JSONValue[] | { [key: string]: JSONValue };
type Fn = (...args: JSONValue[]) => void
function cancellable(fn: Fn, args: JSONValue[], t: number): Function {
const targetTimeOut = setTimeout(() => fn(...args), t)
return function cancelFn() {
clearTimeout(targetTimeOut)
return targetTimeOut
}
};