chore: migrate engine utility and support modules to TypeScript - #400
Conversation
birme
left a comment
There was a problem hiding this comment.
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.
Summary
util.js,preflight.js,subtitle_slicer.js,chaos_monkey.js) to TypeScript — type-only, no behavioral change. Depends on chore: establish incremental TS migration scaffolding and CI gate #372 (scaffold, merged).Changes
git mv.js→.ts for all four;module.exportsshapes 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.anyat dynamic interop (m3u8 objects, node-fetch/AbortController, restify req/res, Buffer/stream plumbing).declare(WaitTimeGenerator,SubtitleSlicer) so no field initializer is emitted undertarget es2022's defaultuseDefineForClassFields— constructor assignments stay the sole runtime writes. Neither class usesextends.subtitle_slicer(this.vttFile[uri]guarded by never-truethis.vttFiles.length) preserved as-is (not fixed) to avoid behavior change.Test plan
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