TypeScript type definitions for the Steam client (steam-types npm package). Types cover the Steam SharedJSContext window — SteamClient and all its submodules, plus global store/manager objects. Types are auto-generated by running scripts against a live Steam client via Chrome DevTools Protocol (CDP).
steamtypes/
├── scripts/ # Generation & validation scripts (dev-only, not published)
├── src/ # Published TypeScript type definitions
├── tests/ # Vitest tests for the scripts
├── build/ # Compiled inject script output (gitignored)
├── diffs/ # Diff output from validate-types (gitignored)
├── dist/ # Built package output (gitignored)
└── patches/ # Bun patch for @steambrew/client
validate-types.ts— Main developer script. Connects to Steam via CDP, injects the convert script, runsconvertToTypescript()on each mapped object, compares results against existing source files, and writes diffs.- Requires Steam running with CEF debugging on port 8080 (it almost always is)
- Requires
build/scripts/convert-to-typescript.jsto exist first (runbun run build-convert-debug)
update-globals.ts— Updatessrc/Globals/index.tswith actual window properties discovered from Steam. Called automatically byvalidate-types.ts.
-
convert-to-typescript/— Core JS->TS conversion pipeline (runs inside Steam's browser context)index.ts— Initialises globaltsProjectand exportsconvertToTypescriptconverter.ts— Main orchestrator: processes interfaces, merges, generates outputinterface-generation.ts— CreatesTypeScriptInterfaceobjects from JS objectsinterface-merger.ts— Merges similar interfaces using Jaccard similarity (≥65% overlap)function-extraction.ts— Extracts function parameter/return types via ts-morphprop-type-detection.ts— Detects property types from runtime valuesreplace-duplicate-types.ts— Handles type deduplication after mergetypes.ts— Internal data model (TypeScriptInterface,InterfaceProperty,FunctionInfo,ConversionContext)Type.ts—Typeclass hierarchy (PrimitiveType, InterfaceType, UnionType, etc.)utils.ts— Context management, property enumeration helpersfill-app-data.ts— Helper to populate app data for richer type extractionindex.ts— Entry point used bybuild-convert-debugesbuild bundle
-
compare/— Interface comparison & auto-correction (runs on the host, uses ts-morph)interface-comparator.ts— Core: compares source (generated) vs target (existing file), queues interfaces, applies corrections, produces diffsinterface-checker.ts— Entry:compareInterfaces()called fromvalidate-types.tscompare-methods.ts— Method signature comparison logiccompare-properties.ts— Property type comparison logichandle-interfaces.ts— Adds missing interfaces, finds similar onestype-comparator.ts— Deep type comparison utilitiesshared.ts— Shared state (queue, logger, JSDoc tag helpers,CustomJsDocTags)
-
maps/— Declares what Steam objects map to what TypeScript filesindex.ts— ExportsinterfaceMapsarray andIMap()/GMap()factory helpersSteamClient.ts— AllSteamClient.*sub-interface mappingsGlobal.ts— Global store/manager mappings (usesGMap->src/types/Global/)FriendStore.ts,SteamUIStore.ts,Modules.ts,Shared.ts— Category-specific mapsInterfaceMapshape:{ file, interfaceName, objectExpression, initFunction?, condition?, ignoredProperties? }
src/
├── index.ts # Package entry, re-exports all types
├── Globals/
│ └── index.ts # Global window declarations (declare global + Window interface) — auto-updated
├── Runtime/ # Runtime helpers distributed with the package
└── types/
├── index.ts # Re-exports all type categories
├── system-information.ts # Auto-generated: Steam version info
├── shared/ # Shared types used across modules
├── Global/
│ ├── App.ts
│ ├── AppAchievementProgressCache.ts
│ ├── managers/ # ConnectionManager, LocalizationManager, etc.
│ └── stores/ # AppStore, AppDetailsStore, FriendStore, SteamUIStore, etc.
├── SteamClient/
│ ├── index.ts # Main SteamClient interface
│ ├── shared.ts # Shared SteamClient types
│ ├── Apps.ts, Auth.ts, ... (one file per submodule)
│ └── System/ # SteamClient.System and its sub-interfaces
├── Modules/ # Module types
└── Protobufs/ # Protobuf message types (generated by proto:generate)
- Each file in
src/types/corresponds to oneIMapentry inscripts/maps/ src/Globals/index.tsis auto-managed — do not manually reorder global property lists; the script keeps them alphabetical- Files use
@compareOriginalNameJSDoc tag to track renames;@ignoreto skip comparison
Two test suites configured in vitest.config.ts:
-
tests/compare/— Tests for thescripts/compare/interface comparatorshared.ts— Test helpers:createTest(),runComparisonTest(),assertDiff()test-cases/— TypeScript test case files (target + source interface strings + expected diff snapshots)__snapshots__/— Vitest snapshot files- Each
*.test.tsfile imports a test case file and callscreateTest()
-
tests/convert/— Tests for thescripts/convert-to-typescript/converterfunctions/— Function extraction test casesproperties/— Property type detection test casesprotobufs/— Protobuf type test cases
# Run all tests
bun run test
# Run tests with coverage (files with 100% coverage are hidden by skipFull option)
bun run test:coverage
# Run tests with coverage showing all files (including 100% covered) only run when the file doesn't appear in the normal command
bun run test:coverage --coverage.reporter=text
# IMPORTANT: NEVER pipe test or coverage output through `tail`, `head`, etc.
# Vitest detects the truncated TTY and shortens its own per-file uncovered-line list,
# hiding the actual line numbers you need. ALWAYS run the command unpiped.
# Build the inject script (required before validate-types)
bun run build-convert-debug # dev build with identifiers
bun run build-convert # minified build
# Validate & update types against live Steam client (Steam must be running on port 8080)
bun validate-types
bun validate-types --diff # writes diffs/ folder
bun validate-types --force # force re-inject script
bun validate-types [filter] # e.g. "SteamClient" to filter by file path
# Generate protobuf types
bun run proto:generate
# Build for publish
bun run build
# Lint
bun run lint
bun run lint:fix- Steam must be running with CEF remote debugging on port 8080 (it always is)
- Build the inject bundle:
bun run build-convert-debug - Run
bun validate-typeswhich: a. Connects to Steam'sSharedJSContextvia CDP b. Injectsbuild/scripts/convert-to-typescript.jsinto the window c. Callswindow.convertToTypescript(SteamClient.Apps, 'Apps', {...})for each map entry d. Compares generated interface withsrc/types/<file>.tsusingscripts/compare/e. Auto-corrects differences in the source file in-place f. Optionally writes.difffiles todiffs/ - Apply diffs manually or via
apply-diffs.sh/apply-diffs.ps1
- Add an
IMaporGMapentry in the appropriatescripts/maps/*.tsfile - Create the target file at
src/types/<file>.ts(or letvalidate-typescreate it) - Run
bun validate-typesto populate/update it - Export the new interface from
src/types/index.ts
| Tag | Purpose |
|---|---|
@compareOriginalName <name> |
Tracks a renamed property/interface for comparison |
@currentValue <value> |
Documents the current runtime value of a property |
@ignore |
Tells the comparator to skip this member |
- ts-morph is used throughout for AST manipulation both in conversion and comparison
- The convert script runs in an in-memory ts-morph project inside Steam's CEF browser
- Interface merging uses Jaccard similarity: interfaces with ≥65% property overlap are merged
src/Globals/index.tshas both adeclare global { let X: T }block andinterface Window { X: T }— both are kept in sync and sorted alphabeticallytsconfig.build.jsonbuilds onlysrc/for publish;tsconfig.jsoncovers everything- The package exports subpath aliases:
steam-types/Global/*,steam-types/Modules/*, etc.