Visit complete TypeScript roadmap

← Back to Topics List

Ambient Modules

Ambient modules in TypeScript are used to declare external modules or third-party libraries in a TypeScript program. Ambient modules provide type information for modules that have no TypeScript declarations, but are available in the global scope.

Here’s an example of how you can use ambient modules in TypeScript:

// myModule.d.ts
declare module 'my-module' {
  export function doSomething(): void;

// main.ts
import * as myModule from 'my-module';

In this example, we declare an ambient module “my-module” in the myModule.d.ts file. This declaration provides type information for the “my-module” module, including the “doSomething” function that is exported from the module.

Learn more from the following links:

Community is the 6th most starred project on GitHub and is visited by hundreds of thousands of developers every month.

Roadmaps Best Practices Guides Videos Store YouTube by Kamran Ahmed

Community created roadmaps, articles, resources and journeys to help you choose your path and grow in your career.

© · FAQs · Terms · Privacy


The leading DevOps resource for Kubernetes, cloud-native computing, and the latest in at-scale development, deployment, and management.