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
- Your code has no type errors
- The program prints true and then false
- retries must be a number
- features cannot be changed (readonly)
- 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.
Press Run to see the page.
Console
Nothing printed yet.