Command Palette

Search for a command to run...

Hectal
Phase 11: Modules and Declaration Files
TypeScript · Exercise 5 of 5 Previous
Intermediate

A typed global config

A build tool puts a global __CONFIG__ object on the page. Declare its type in declare global with var: apiUrl: string, retries: number, features: readonly string[].

Then write hasFeature(name: string): boolean, which tells whether the config lists a feature. The starter sets __CONFIG__ for you at startup (real tools do this at build time). The program prints true and then false.

What Check tests

  1. Your code has no type errors
  2. The program prints true and then false
  3. retries must be a number
  4. features cannot be changed (readonly)
  5. hasFeature takes a string only

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.