npm.io
40.10.5 • Published 3d ago

electron-types

Licence
MIT
Version
40.10.5
Deps
1
Size
1.0 MB
Vulns
0
Weekly
1.2K
Stars
1

electron-types

CI 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@40.10.5
# or
yarn add -D electron-types@40.10.5
# or
pnpm add -D electron-types@40.10.5

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

# Install dependencies
yarn install

# Extract types from latest electron
yarn extract

# Extract types from a specific version
yarn extract 39.2.7

# Build package for a specific version (extract + update version)
yarn build 39.2.7

# Test that types work correctly
yarn test

# Check if a new version needs to be published
yarn check-versions

License

MIT - Same as Electron

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

Keywords