TypeScript · Senior · Question 32 of 75
What is the declare keyword for?
declare const __APP_VERSION__: string;- ✓Correct answer: Describing something that exists at runtime without generating code
- 2Declaring a variable that the compiler will create
- 3Making a variable global at runtime
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.