Command Palette

Search for a command to run...

Hectal
Phase 6: Classes and Object-Oriented TypeScript
TypeScript · Exercise 6 of 6 Previous
Advanced

Write a Method Decorator

counted is a standard method decorator that should count how many times each decorated method is called, in the calls object, while still returning the method's result.

Finish the wrapper: increase calls[name] and then call the original method. The program should print pong, 2 and 1.

What Check tests

  1. Your code has no type errors
  2. The console prints pong and 2 1
  3. The decorated method keeps its signature
  4. The decorated method still checks its arguments

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

Runs in your browser. Your code is saved here.

Console

Nothing printed yet.