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
- Your code has no type errors
- The program prints theme: dark
- A theme of "blue" is rejected
- 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.
Press Run to see the page.
Console
Nothing printed yet.