Fix a Flow-to-TypeScript Converted Codebase Against a Failing Jest Suite

Quick Overview

A bug bash on a codebase converted from Flow to TypeScript, with a failing Jest test suite and three open issues to fix. It asks how to triage the failures, how Flow constructs such as maybe types, exact objects and utility types map to TypeScript, and how to confirm each fix with both Jest and the type checker.

Fix a Flow-to-TypeScript Converted Codebase Against a Failing Jest Suite

Company: Stripe

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: hard

Interview Round: Onsite

In a bug bash round you get a small codebase that is being converted from Flow to TypeScript. The source files and their type annotations have been moved to TypeScript, the repository has a Jest test suite, and three issues are open against the converted code. You have about an hour to resolve all three. You can run the tests and the TypeScript compiler, read every file and change any file. The three original issues are not reproduced here. The parts below ask how you would run the session and which defects you expect a Flow-to-TypeScript conversion to leave behind. ### Clarifying Questions - Is the target a green Jest run, a clean type check with `tsc`, or both? - May a fix use `any`, a type assertion or `// @ts-ignore`, or must every fix be properly typed? - Does Jest compile the TypeScript with Babel or with `ts-jest`, and is the compiler in `strict` mode? - May you change the Jest and TypeScript configuration, or only source files? - Can a test be wrong after the conversion, or are the tests the specification? ### Part 1: Triage a failing suite The suite fails when you first run it. Describe your first ten minutes: what you run, how you turn the raw failures into a short list of separate problems, and how you decide which one to fix first. ```hint Separate the failure kinds A type error, a test-runner configuration problem and a behavior change are reported by different tools and look different in the output. Decide which tool tells you about each. ``` #### What This Part Should Cover - The first commands and what each one reports. - Grouping many error lines into a few root causes. - An order of work that fits the hour. ### Part 2: Flow constructs that convert badly For each Flow construct below, give its TypeScript equivalent and describe the defect a naive or tool-driven conversion can introduce. Say which defects only fail the type check and which can make a Jest test fail at runtime. - Maybe types (`?T`), and optional properties typed with a maybe type (`prop?: ?T`). - Exact object types (`{| ... |}`). - `mixed`. - Utility types such as `$Keys<T>`, `$Values<T>`, `$ReadOnly<T>`, `$Shape<T>` and `$PropertyType<T, K>`. - `import type` and modules that re-export types. ```hint Where types reach runtime Type annotations are erased before the tests run. Look for code that was edited during the conversion and for anything the compiler still emits. ``` #### What This Part Should Cover - A correct TypeScript mapping for each construct. - How `null` and `undefined` are handled in each type system. - Which defects change runtime behavior and which affect only the type check. ### Part 3: Make the test suite trustworthy again How do you make sure Jest compiles and runs every TypeScript source and test file after the conversion? Once the suite is green, how do you show that each fix is real, with no cast or suppression comment hiding the error and no tests that silently stopped running? ```hint Count the tests Compare what Jest collects and runs now with what it collected before the conversion. ``` #### What This Part Should Cover - The Jest settings that decide which files are collected and how TypeScript is compiled. - Signs that a fix suppressed an error without correcting it. - A final check that covers both the tests and the type checker. ### What a Strong Answer Covers - Triage that turns raw failures into root causes within the first minutes. - Accurate Flow-to-TypeScript mappings, with attention to `null` and `undefined`. - Fixes that keep the code type-safe. - Verification through both Jest and `tsc`, including the number of tests run. - Working out loud and pacing the hour under time pressure. ### Follow-up Questions - A fix needs a type that Flow expressed as an exact object. How would you model it in TypeScript so callers cannot pass extra fields? - A third-party library had Flow definitions from `flow-typed` but ships no TypeScript types. What are your options? - How would you migrate a large codebase in stages so that Flow and TypeScript files coexist? - After the migration, how would you keep new `any` and `@ts-ignore` from creeping back in?

Overview: A bug bash on a codebase converted from Flow to TypeScript, with a failing Jest test suite and three open issues to fix. It asks how to triage the failures, how Flow constructs such as maybe types, exact objects and utility types map to TypeScript, and how to confirm each fix with both Jest and the type checker.

Read the full Stripe Software Engineer interview experience this question came from

Stripe logo
Stripe
Nov 14, 2026
hardSoftware EngineerOnsiteSoftware Engineering Fundamentals
0
0

In a bug bash round you get a small codebase that is being converted from Flow to TypeScript. The source files and their type annotations have been moved to TypeScript, the repository has a Jest test suite, and three issues are open against the converted code. You have about an hour to resolve all three. You can run the tests and the TypeScript compiler, read every file and change any file.

The three original issues are not reproduced here. The parts below ask how you would run the session and which defects you expect a Flow-to-TypeScript conversion to leave behind.

Clarifying Questions Guidance

  • Is the target a green Jest run, a clean type check with tsc , or both?
  • May a fix use any , a type assertion or // @ts-ignore , or must every fix be properly typed?
  • Does Jest compile the TypeScript with Babel or with ts-jest , and is the compiler in strict mode?
  • May you change the Jest and TypeScript configuration, or only source files?
  • Can a test be wrong after the conversion, or are the tests the specification?

Part 1: Triage a failing suite

The suite fails when you first run it. Describe your first ten minutes: what you run, how you turn the raw failures into a short list of separate problems, and how you decide which one to fix first.

What This Part Should Cover Guidance

  • The first commands and what each one reports.
  • Grouping many error lines into a few root causes.
  • An order of work that fits the hour.

Part 2: Flow constructs that convert badly

For each Flow construct below, give its TypeScript equivalent and describe the defect a naive or tool-driven conversion can introduce. Say which defects only fail the type check and which can make a Jest test fail at runtime.

  • Maybe types ( ?T ), and optional properties typed with a maybe type ( prop?: ?T ).
  • Exact object types ( {| ... |} ).
  • mixed .
  • Utility types such as $Keys<T> , $Values<T> , $ReadOnly<T> , $Shape<T> and $PropertyType<T, K> .
  • import type and modules that re-export types.

What This Part Should Cover Guidance

  • A correct TypeScript mapping for each construct.
  • How null and undefined are handled in each type system.
  • Which defects change runtime behavior and which affect only the type check.

Part 3: Make the test suite trustworthy again

How do you make sure Jest compiles and runs every TypeScript source and test file after the conversion? Once the suite is green, how do you show that each fix is real, with no cast or suppression comment hiding the error and no tests that silently stopped running?

What This Part Should Cover Guidance

  • The Jest settings that decide which files are collected and how TypeScript is compiled.
  • Signs that a fix suppressed an error without correcting it.
  • A final check that covers both the tests and the type checker.

What a Strong Answer Covers Guidance

  • Triage that turns raw failures into root causes within the first minutes.
  • Accurate Flow-to-TypeScript mappings, with attention to null and undefined .
  • Fixes that keep the code type-safe.
  • Verification through both Jest and tsc , including the number of tests run.
  • Working out loud and pacing the hour under time pressure.

Follow-up Questions Guidance

  • A fix needs a type that Flow expressed as an exact object. How would you model it in TypeScript so callers cannot pass extra fields?
  • A third-party library had Flow definitions from flow-typed but ships no TypeScript types. What are your options?
  • How would you migrate a large codebase in stages so that Flow and TypeScript files coexist?
  • After the migration, how would you keep new any and @ts-ignore from creeping back in?