You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Finish the type-safety track started in #28 by converting the remaining // @ts-check-annotated .js files in packages/dredd/lib to real .ts, replacing JSDoc type annotations with native TypeScript signatures.
lib/ is already mixed: 22 .ts + 39 .js. The toolchain handles it today — tsconfig is allowJs + node16 + strict, tests run via ts-node, and the recently-added lib/validation/ module (8 .ts files) built, tested, and shipped cleanly. No tooling changes are needed.
With type-checking already done, conversion is largely mechanical: JSDoc @param {T} / @returns → real signatures, tightening any along the way. The hard part (making the code type-check) is behind us.
Scope
Rename each // @ts-checklib/**/*.js → .ts and replace JSDoc types with native TS.
No behaviour changes and no change to the published surface: the package stays CommonJS (main: build/index.js, no "type": "module"); tsc emits CommonJS regardless of source extension, so consumers are unaffected.
Suggested order (bottom-up: foundation & leaves first)
Converting high-fan-in foundation modules first means their types immediately benefit every importer as those get converted. Grounded in current lib fan-in:
Reporters: reporters/{BaseReporter,DotReporter,CLIReporter,…}.js then configureReporters.js.
Hubs last (high internal fan-out → most any leakage until neighbours are typed): Hooks.js, addHooks.js, HooksWorkerClient.js, init.js, Dredd.js, CLI.js, TransactionRunner.js.
Summary
Finish the type-safety track started in #28 by converting the remaining
// @ts-check-annotated.jsfiles inpackages/dredd/libto real.ts, replacing JSDoc type annotations with native TypeScript signatures.Why now
// @ts-checkevery lib file) is complete — 38/39 files are checked understrict(onlylib/index.jsis deferred to the ESM work in [P2] Migrate packages from CommonJS to ESM #29).lib/is already mixed: 22.ts+ 39.js. The toolchain handles it today —tsconfigisallowJs+node16+strict, tests run viats-node, and the recently-addedlib/validation/module (8.tsfiles) built, tested, and shipped cleanly. No tooling changes are needed.@param {T}/@returns→ real signatures, tighteninganyalong the way. The hard part (making the code type-check) is behind us.Scope
// @ts-checklib/**/*.js→.tsand replace JSDoc types with native TS.main: build/index.js, no"type": "module");tscemits CommonJS regardless of source extension, so consumers are unaffected.Out of scope
lib/index.js— the package entry and the only un-@ts-checked file; convert it as part of the CommonJS→ESM migration ([P2] Migrate packages from CommonJS to ESM #29), not here.Suggested order (bottom-up: foundation & leaves first)
Converting high-fan-in foundation modules first means their types immediately benefit every importer as those get converted. Grounded in current
libfan-in:createConsoleLogger.js→logger.js(imported by 19 files) →reporters/reporterOutputLogger.js(10). Already grouped this way in [P1] Incrementally type-check packages/dredd/lib (.js → typed) #28.expandTilde.js,which.js,ignorePipeErrors.js,getGoBinary.js,getProxySettings.js,hooksLog.js,compileTransactionName.js,prettifyResponse.js.httpClient.js,readLocation.js,performRequest.js,configUtils.js,annotationToLoggerInfo.js.configuration/{validateConfig,normalizeConfig,getProxySettings,applyLoggingOptions,applyConfiguration,index}.js.reporters/{BaseReporter,DotReporter,CLIReporter,…}.jsthenconfigureReporters.js.anyleakage until neighbours are typed):Hooks.js,addHooks.js,HooksWorkerClient.js,init.js,Dredd.js,CLI.js,TransactionRunner.js.index.js— last, with [P2] Migrate packages from CommonJS to ESM #29.Acceptance criteria
lib/**/*.jsexceptindex.jsis converted to.tswith native types (no remaining// @ts-checkpragmas inlib).tsc --buildpasses understrict;yarn lint,yarn test, smoke all green per PR.Follow-on to #28. Interacts with #29 only for
index.js.