Skip to content

chore: migrate engine state-store modules to TypeScript - #398

Merged
birme merged 2 commits into
masterfrom
issue-373/ts-migrate-state-store
Sep 4, 2026
Merged

chore: migrate engine state-store modules to TypeScript#398
birme merged 2 commits into
masterfrom
issue-373/ts-migrate-state-store

Conversation

@birme

@birme birme commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Changes

  • git mv .js→.ts for: shared_state_store, memory_state_store, memcached_state_store, redis_state_store, session_state, session_live_state, playhead_state.
  • New engine/state_store_types.ts: shared contracts — IStateStore (implemented by memory/memcached/redis backends), ISharedStateStoreOpts, ILeaderCache, SharedStates.
  • Interop: used plain erasable CommonJS (const X = require('./x.js') + module.exports = X) and import type so still-.js consumers (session.js, session_live.js, stream_switcher.js) and specs load the modules unchanged; no export =/namespace syntax (incompatible with Node native type-stripping used by the jasmine source-tree run).
  • New spec/helpers/ts-resolve.js: test-time-only jasmine resolver shim that retries a failed .js/extensionless require against the .ts source (matched by the existing helpers/**/*.js glob). Production uses compiled dist/ (all .js) and is unaffected.

Test plan

  • PROOF: npm run build → tsc clean (exit 0); npm test → 113 specs, 0 failures, 7 pending (identical to baseline — no behavior change).

Closes #373

🤖 Automated via Channel Engine Dev daily-backlog-pr skill

node-engineer and others added 2 commits September 4, 2026 14:21
Convert the engine state-store layer to TypeScript as a type-only migration
with no change to public APIs or runtime behavior:

- shared_state_store, memory/memcached/redis_state_store, session_state,
  session_live_state, playhead_state (.js -> .ts via git mv).
- Add shared state-store type definitions (IStateStore, ISharedStateStoreOpts,
  ILeaderCache, SharedStates) in engine/state_store_types.ts.
- Keep CommonJS require/module.exports interop (erasable syntax) so the still
  -.js consumers and specs load the modules unchanged.
- Add a jasmine helper that resolves .js requires to .ts sources during the
  source-tree test run (build/test-time shim only).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

@birme birme left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pr-reviewer verdict: APPROVE

PROOF: npm run build && npm test → 113 specs, 0 failures, 7 pending (matches master baseline). Also verified under NODE_OPTIONS=--no-experimental-strip-types (simulating CI Node 20) → 113/0. CI green on 20.x and 22.x.

  • Genuine type-only port: all 7 converted files are byte-identical modulo whitespace/annotations; exported shapes consumed by the still-.js files (session.js, stream_switcher.js) and specs are preserved.
  • Class-field emit hazard (target es2022 → useDefineForClassFields defaults true) handled correctly: subclasses use declare for parent-owned cache/cacheTTL, so no this.cache = undefined clobbers the base-assigned value. Confirmed in emitted dist/.
  • spec/helpers/ts-resolve.js is sound and strictly test-only: .js.ts resolve fallback + require.extensions['.ts'] transpile via the already-present typescript devDep; does not touch require.extensions['.js']; production runs compiled dist/ and is unaffected.
  • No trademarks. Conventional-commit messages referencing #373.

Merging.

@birme
birme merged commit b4f45b7 into master Sep 4, 2026
2 checks passed
@birme
birme deleted the issue-373/ts-migrate-state-store branch September 4, 2026 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore: migrate engine state-store modules to TypeScript

1 participant