Skip to content

Repository files navigation

electron-types

npm version npm downloads

TypeScript type definitions extracted from the electron package.

Why?

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).

Installation

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-types

Usage

Add 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 = /* ... */;

Version Matching

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.

How It Works

This package is automatically updated via CI:

  1. A scheduled GitHub Action checks for new electron releases every 6 hours
  2. When a new version is detected, it downloads the electron package
  3. Extracts the electron.d.ts type definitions
  4. Publishes to npm using Trusted Publisher (OIDC) with provenance attestation

Development

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-versions

License

MIT - Same as Electron

The type definitions are extracted from the Electron project, which is licensed under the MIT license.

About

TypeScript type definitions extracted from the electron package

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Contributors

Languages