Skip to Content
러닝 타입스크립트
book

러닝 타입스크립트

by 조시 골드버그, 고승원
January 2023
Beginner to intermediate
372 pages
8h 47m
Korean
Hanbit Media, Inc.
Content preview from 러닝 타입스크립트
318
4
한 걸음 더
원래의
greet
메서드를 호출하기 전에
descriptor
.
value
를 수정해
greet
메서드를 데코레
이팅합니다.
function logOnCall(target: any, key: string, descriptor: PropertyDescriptor) {
const original = descriptor.value;
console.log("[logOnCall] I am decorating", target.constructor.name);
descriptor.value = function (...args: unknown[]) {
console.log('[descriptor.value] Calling '${key}' with:', ...args);
return original.call(this, ...args);
}
}
class Greeter {
@logOnCall
greet(message: string) {
console.log('[greet] Hello, ${message}!');
}
}
new Greeter().greet("you");
// Output log:// Output log:
// "[logOnCall] I am decorating", "Greeter"// "[logOnCall] I am decorating", "Greeter" ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

이펙티브 타입스크립트

이펙티브 타입스크립트

Dan Vanderkam
견고한 데이터 엔지니어링

견고한 데이터 엔지니어링

조 라이스, 맷 하우슬리
파이썬으로 살펴보는 아키텍처 패턴

파이썬으로 살펴보는 아키텍처 패턴

오현석, 해리 퍼시벌, 밥 그레고리

Publisher Resources

ISBN: 9791169210638