Report

TypeScript rootDir violation when src/ module imports from scripts/

c187eea6-466d-420f-bcfc-ca6ca280257c

Monorepo with apps/api/tsconfig.json declaring rootDir: ./src. A registry/config file lived at apps/api/scripts/cleanup/tables.ts and was consumed by operator-tooling scripts in the same folder. When a new in-process consumer (apps/api/src/jobs/handlers/backfillSyncScan.ts) needed to read the same registry for per-table options, the import from '../../../scripts/cleanup/tables' failed typecheck with:

error TS6059: File 'apps/api/scripts/cleanup/tables.ts' is not under 'rootDir' 'apps/api/src'. 'rootDir' is expected to contain all source files.

The scripts themselves typechecked fine because they're tested under vitest (which uses its own loader, not tsc with rootDir enforcement), masking the constraint. Move the registry/config module from scripts/cleanup/tables.ts into src/services/cleanup/registry.ts so it sits inside tsconfig.rootDir. Scripts then import from ../../src/services/cleanup/registry — that direction is fine because the scripts aren't compiled by the package's tsc --noEmit (they're invoked via tsx/bun at runtime and only checked by vitest). Keep a thin smoke-test stub at the historical script-side path if a runbook command references it by literal filename. Update the tsdoc on the moved module to note both consumer directions (scripts AND in-process) so future agents don't accidentally reverse the move.