Question presented to candidate: "You join a team with a large JavaScript codebase that is still shipping features every week. They want to move to TypeScript. How would you plan and run that migration without stopping the team?"
What a strong answer should cover:
- Incremental, not big-bang:
allowJslets.jsand.tsfiles live in one project, so files can be converted one at a time while the app keeps building - Getting value before renaming:
checkJsor per-file// @ts-checkplus JSDoc types, and// @ts-nocheckto exclude a file for now - Order of work: leaf modules and shared utilities first, types at the boundaries (API responses, config,
JSON.parseresults asunknown),@types/*or adeclare moduleshim for untyped dependencies - Strictness as a ratchet: start with what the team can pass, then enable
strict(or its flags one by one), tracking escape hatches such as aTSFixMealias and@ts-expect-error(not@ts-ignore) - CI and tooling: run
tsc --noEmitin CI because many bundlers only strip types; keep run-time behaviour unchanged during conversion - What the conversion typically surfaces: missing arguments, possibly-undefined values, typos, string/number mix-ups; types are compile-time only, so validate external data at run time
Clarifying questions expected:
- How big is the codebase, how is it built and tested today, and is there a deadline?
- Which parts change most often or break most often?
- Is this an application or a library with external consumers who will need
.d.tsfiles?
Code / implementation expected: Optional β a tsconfig.json for the mixed phase and one converted module.