-
Notifications
You must be signed in to change notification settings - Fork 0
⭐ TypeScript Migration
A full .js → .ts migration, chosen over a lighter JSDoc + tsconfig checkJs approach for its stronger guarantees. Plain Sequelize 6 generics for model typing, not the sequelize-typescript decorator library — a straight typing upgrade, not a structural rewrite. tsx for local dev/CI, no separate tsc build step.
The original scope decision got reversed once, for real friction, not preference. The plan was to retrofit all 20 already-committed .js files to .ts first, before writing anything new in TypeScript. Retrofitting config.js first broke models/index.js's hardcoded require(".../config/config.js") path — a preview of the cascade every other retrofit would trigger. Reversed: the 20 existing files stayed .js for the time being, every new file went straight to .ts, and the retrofit itself became a dedicated later pass.
The retrofit pass, once it actually happened, cascaded exactly as feared — but in a contained, single batch rather than file-by-file: converting models/index.ts forced every remaining .js consumer of ../models to convert in the same pass, since plain require() fundamentally cannot resolve a .ts target under Vitest. models/index.ts's dynamic fs.readdirSync-based model loader hit the identical wall and was rewritten to explicit static imports of the 4 known models — a real architecture simplification (the schema is fixed, so dynamic scanning was never buying anything), not just a mechanical port. Result: zero .js files remain anywhere in backend/.
A real compatibility issue surfaced immediately on setup: typescript@latest resolved to 7.0.2, which typescript-eslint's own peer range (>=4.8.4 <6.1.0) doesn't support — installing it broke yarn lint project-wide, not just .ts files. Pinned to 6.0.3, the newest stable release typescript-eslint actually supports.