Command Palette

Search for a command to run...

Hectal
Phase 16: Advanced TypeScript
TypeScript · Exercise 6 of 6 Previous
Advanced

Merge two interfaces and attach a counter

Settings is declared once with theme. Add a second interface Settings declaration that adds fontSize: number, so a Settings value needs both.

Then give the function counter a property calls (a number starting at 0) with a namespace after the function, and make the function add one to it each call.

What Check tests

  1. Your code has no type errors
  2. The program prints the settings and the call count
  3. A Settings value without fontSize is rejected
  4. counter.calls is a number

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.