← 문제 목록
고급
TypeScript
100P
데코레이터 타입 안전성
다음 TypeScript 코드에서 버그를 찾으세요:
TYPESCRIPT
function sealed(constructor: Function) {
Object.seal(constructor);
Object.seal(constructor.prototype);
}
function log(
target: any,
propertyKey: string,
descriptor: PropertyDescriptor
) {
const original = descriptor.value;
descriptor.value = function (...args: any[]) {
console.log(`호출: ${propertyKey}`);
return original.apply(this, args);
};
}
@sealed
class Calculator {
@log
add(a: number, b: number): number {
return a + b;
}
}
const calc = new Calculator();
Calculator.prototype.subtract = function (a: number, b: number) {
return a - b;
};
0명 풀이 · 정답률 0%