TypeScript type definitions extracted from the electron package.
The official electron package is ~200MB because it includes the Electron binary. If you only need TypeScript types (e.g., for type-checking code that will run in an Electron context), this package provides just the type definitions (~1MB).
Since this package only provides TypeScript types, install it as a dev dependency. Install the version that matches your Electron version (see Version Matching):
npm install -D electron-types
# or
yarn add -D electron-types
# or
pnpm add -D electron-typesAdd electron-types to your tsconfig.json:
{
"compilerOptions": {
"types": ["electron-types"]
}
}Then use the Electron namespace in your code:
const win: Electron.BrowserWindow = /* ... */;
const app: Electron.App = /* ... */;This package's version matches the electron version it was extracted from. For example, electron-types@39.2.7 contains types from electron@39.2.7.
This package is automatically updated via CI:
- A scheduled GitHub Action checks for new electron releases every 6 hours
- When a new version is detected, it downloads the electron package
- Extracts the
electron.d.tstype definitions - Publishes to npm using Trusted Publisher (OIDC) with provenance attestation
Local development requires Node.js 22.13+ for pnpm 11. Enable Corepack once with
corepack enable if pnpm is not already available.
# Install dependencies
pnpm install
# Extract types from latest electron
pnpm extract
# Extract types from a specific version
pnpm extract 39.2.7
# Build package for a specific version (extract + update version)
pnpm build 39.2.7
# Test that types work correctly
pnpm test
# Check if a new version needs to be published
pnpm check-versionsMIT - Same as Electron
The type definitions are extracted from the Electron project, which is licensed under the MIT license.