TypeScript · Senior · Question 32 of 75

What is the declare keyword for?

declare const __APP_VERSION__: string;

Explanation

Ambient declarations tell the compiler about things defined elsewhere: globals injected by the bundler, scripts from a CDN, modules without types (declare module 'legacy-lib'). declare doesn't produce any JS code.

Further reading

Problem with a question

TypeScript · Senior · question 32

Test yourself

Take the TypeScript · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz