Skip to main content
InterviewHubPRO
Section Overview
Q25

Question 25 of 50

Part 2: Advanced Type System & Metaprogramming (Mid-Level)

50%
TypeScript Master (50 Qs)•Part 2: Advanced Type System & Metaprogramming (Mid-Level)

What are Ambient Declarations and `.d.ts` files?

junior LevelCode ExampletypescriptAdvanced Type System

In Simple Words: Ambient declarations describe the shape of existing JavaScript code that has no built-in types (e.g., globals on window, external C-modules, or legacy npm packages). Defined using the declare keyword in .d.ts files. They contain zero executable JavaScript—only type definitions.

typescript
// types/global.d.ts
declare const __BUILD_TIMESTAMP__: string;

declare namespace NodeJS {
  interface ProcessEnv {
    DATABASE_URL: string;
    JWT_SECRET: string;
  }
}