07 / 08

What is downleveling?

Downleveling is the process of TypeScript compiling modern JavaScript syntax down to an older version of JavaScript so it can run in environments that don't support newer features.

Difficulty: 5/10
Topics: target, compiler options, compatibility

Scenario Questions

0-2 years experience
  1. 1

    We need a new component that must run in IE11. How would you set up tsconfig so the emitted JavaScript is compatible?

  2. 2

    If you add optional chaining to a file that’s compiled for ES5, what will the output look like and why?

2-5 years experience
  1. 1

    Our TypeScript library is published with a target of ES2020, but some consumers on Node 10 are seeing syntax errors. Walk me through how you’d debug and fix the downleveling issue.

  2. 2

    Explain why a piece of code using async/await throws at runtime after compilation to ES5, and what steps you’d take to resolve it.

5-8 years experience
  1. 1

    In a monorepo, some packages need to downlevel to ES5 for a legacy web app while others can stay at ES2022. How would you design the build pipeline to handle these mixed targets efficiently?

  2. 2

    Discuss the trade‑offs between downleveling async/await to generator helpers versus pulling in a runtime polyfill for a large single‑page application.

8+ years experience
  1. 1

    We’re planning a multi‑year migration from an ES5 front‑end to a modern ES2022 stack. What architectural guidelines would you establish for downleveling strategy, versioning, and CI/CD to keep backward compatibility while gradually retiring polyfills across teams?

  2. 2

    How would you coordinate cross‑team decisions about downleveling targets to avoid version drift in a large organization with both legacy and cutting‑edge products?

Follow-up Questions

  • What problems can arise if you target a version that's too low for your codebase?
  • How does downleveling interact with source‑map generation and debugging?
  • When might you choose to avoid downleveling altogether?