Skip to main content
D
TypeScript
TypeScript Modules

TypeScript Modules

TypeScript Modules share code securely between different files.

Read Time
5 min read
Difficulty
Beginner
Last Updated
Jun 15, 2026
Version
v1.0.0

Introduction

A massive application cannot live in one single file. TypeScript uses the exact same Module system as modern JavaScript, allowing developers to split their code into hundreds of small files and link them together perfectly.

Example

Example
1/* this exports and imports code */
2// file1.ts
3export const apiKey = "12345";
4
5// file2.ts
6import { apiKey } from './file1';
7console.log(apiKey);

Key Points

  • Use `export` to make a variable or function available to other files.
  • Use `import` to bring that code into a new file.
  • Every file containing an import or export is considered a Module.
  • It keeps large codebases organized and maintainable.

Up Next

Continue your journey with the next topic.

Go to TS Utility Types