8.7 Ambient Enums for Declaration Files
Right, so you’ve decided to venture into the wild west of TypeScript declaration files (.d.ts), where the rules get a little… bendy. Good for you. This is where you make peace with JavaScript code you didn’t write and teach TypeScript how to understand it. And when that JavaScript code has enums, you can’t just waltz in with a normal enum declaration. You need an ambient enum. The declare keyword is your passport here. It tells TypeScript, “Hey, trust me on this. This thing exists at runtime, I’m just describing its shape for you.” You use it in .d.ts files to describe code that lives elsewhere.