tsc step, a ts-loader, or an extra bundler rule.
When TypeScript is a good fit
- You want safer refactors and clearer contracts across extension contexts.
- You share logic between background scripts, content scripts, and UI surfaces.
- You need predictable API usage when working with AI-generated code.
Template examples
new-typescript

content-typescript

Usage with an existing extension
Add TypeScript to an existing extension with the steps below.Installation
- Install TypeScript as a development dependency:
- Initialize the TypeScript configuration file
tsconfig.json:
Configuration
TypeScript detection and requirements
Extension.js looks fortsconfig.json next to your package.json.
- If TypeScript source files are present and
tsconfig.jsonis missing, Extension.js throws an error and asks you to create one. - If Extension.js detects TypeScript through dependencies or configuration without source files, it can scaffold a baseline
tsconfig.json.
Automatic types
Extension.js generatesextension-env.d.ts in your project root during development. This file includes type declarations for Extension.js APIs and browser polyfill types.
Transpilation vs type-checking
The default bundler pipeline compiles TypeScript but does not run fulltsc type-checking as part of bundling.
Recommended scripts:
Next steps
- Learn how Extension.js handles ECMAScript modules.
- Explore styling options like Sass modules.

