Command Palette

Search for a command to run...

Hectal
Phase 11: Modules and Declaration Files
TypeScript · Exercise 1 of 5Next
Beginner

Teach Window about your theme

A script on your page sets window.theme. TypeScript doesn't know Window has that property. Teach it, with a type that only allows "light" or "dark".

Use declare global and an interface Window. The file already has export {};, so it is a module. The program must print theme: dark.

What Check tests

  1. Your code has no type errors
  2. The program prints theme: dark
  3. A theme of "blue" is rejected
  4. A theme of "light" is accepted

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.