Skip to content

chore: migrate engine utility and support modules to TypeScript - #400

Merged
birme merged 1 commit into
masterfrom
issue-375/ts-migrate-utils
Sep 4, 2026
Merged

chore: migrate engine utility and support modules to TypeScript#400
birme merged 1 commit into
masterfrom
issue-375/ts-migrate-utils

Conversation

@birme

@birme birme commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Changes

  • git mv .js→.ts for all four; module.exports shapes preserved exactly (util: named-export object of 17 helpers; preflight: module.exports.handler; subtitle_slicer: class default; chaos_monkey: { loadVod }) so all consumers (session*.ts, state stores, server.ts, specs) resolve unchanged.
  • Concrete types for pure helpers (timer, findNearestValue, isValidUrl, m3u8Header, loadVod, …); any at dynamic interop (m3u8 objects, node-fetch/AbortController, restify req/res, Buffer/stream plumbing).
  • Class fields declared with declare (WaitTimeGenerator, SubtitleSlicer) so no field initializer is emitted under target es2022's default useDefineForClassFields — constructor assignments stay the sole runtime writes. Neither class uses extends.
  • Pre-existing latent bug in subtitle_slicer (this.vttFile[uri] guarded by never-true this.vttFiles.length) preserved as-is (not fixed) to avoid behavior change.

Test plan

  • PROOF: npm run build → tsc clean; npm test → 113 specs, 0 failures, 7 pending; NODE_OPTIONS=--no-experimental-strip-types npm test (CI Node 20 path) → 113/0. Diff is annotation-only under --ignore-all-space.

Closes #375

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

@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 clean; npm test → 113 specs, 0 failures, 7 pending; NODE_OPTIONS=--no-experimental-strip-types npm test → 113/0. CI green on 20.x/22.x.

Faithful type-only port. All four export shapes byte-identical to master. --ignore-all-space diff shows only erasable syntax (annotations, ? markers, as any/as number casts). Spot-checked fetchWithRetry, filterQueryParser/applyFilter, codecsFromString, WaitTimeGenerator, findNearestValue — no conditionals/bounds/defaults altered. Verified in emitted dist/ that declare fields (WaitTimeGenerator, SubtitleSlicer) produce NO initializers, so the es2022 useDefineForClassFields clobber is avoided and constructor assignments remain the sole writes. The three no-op casts are runtime-identical to the original coercions.

Non-blocking: pre-existing latent dead-code bug in subtitle_slicer (this.vttFile[uri] guarded by never-true this.vttFiles.length) confirmed identical on master and correctly preserved — recommend a follow-up bug issue. Merging.

@birme
birme merged commit 3b06ba0 into master Sep 4, 2026
2 checks passed
@birme
birme deleted the issue-375/ts-migrate-utils branch September 4, 2026 14:55
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 utility and support modules to TypeScript

1 participant