You join a team with a large JavaScript React codebase. How would you migrate it to TypeScript without stopping feature work?
What the interviewer wants to hear
- Incremental migration with allowJs and checkJs, converting file by file
- Start from leaves and shared utilities, then types for API models
- Tighten strictness gradually and track progress, for example with a count of any or ts-expect-error
- Keep CI green: type checks in the pipeline, no big-bang rewrite branch
- Agree on conventions, give training and make new files TypeScript by default
Model answer
I would never do a big-bang rewrite. First I add TypeScript with allowJs so .js and .ts files live together, wire tsc --noEmit into CI, and agree on one rule: new files are written in TypeScript. Then I convert from the leaves up: shared utilities, hooks and design system components first, because many files depend on them and their types spread value quickly. Early on I define types for API models, ideally generated from an OpenAPI schema or validated with Zod, since data shapes cause many real bugs. I start with a loose config and tighten it over time, enabling strict and noImplicitAny per folder or using ts-expect-error comments as a visible to-do list, and I track the number of remaining any and JavaScript files on a dashboard. Teams convert files when they touch them for features, so migration rides along with normal work. Codemods help with mechanical changes, and short pairing sessions spread good patterns.
Can you answer it under time pressure?
Take a timed hard round and get scored on every answer.
More hard Frontend Developer questions
- How would you design and build a shared component library (design system) used by several product teams?
- A page must show a table with 50,000 rows and stay smooth while scrolling and filtering. How would you build it?
- What are the main security risks for a frontend application and how do you protect against them?
- Your company wants to split a large frontend into micro-frontends. What are the trade-offs and how would you approach it?
- What are React Server Components, and how do they change the way you build a React app?
- How would you design a web app that keeps working offline, for example for field workers with poor connectivity?
- How would you build the frontend for a real-time feature like a shared task board where many users edit at the same time?
- Users report that your single-page app becomes slow and crashes after being open for a few hours. How do you investigate and fix it?
- How do you know your frontend is healthy in production? Describe the monitoring you would set up.