skip to content

As lead of a JavaScript codebase, what standing rule would you set for adopting syntax from proposals before TC39 Stage 4, and what do you weigh?

level: principalimportance: nice to knowfreq 20%

answer

  1. two risks, one stage number
  2. blast radius: app versus library
  3. exception, owner, exit plan
  4. enforce it in tooling
  5. strictness has a cost too

basics

~20 s

Set the rule by stage and blast radius: default to Stage 4 syntax your targets can run, allow Stage 3 by recorded exception with an owner and exit plan, and keep anything earlier out of shipped code.

solid answer

~50 s

I would treat it as two risks: spec risk, which the stage measures, and runtime risk, which only our browser and Node targets answer. My default: Stage 4 syntax is free once the targets or the build handle it. Stage 3 syntax needs a recorded exception naming an owner, why it beats waiting, and how we migrate if semantics change. Anything below Stage 3 stays out of shipped code, since no implementation recommendation exists yet and the process itself calls Stage 2 polyfills not for production use. I would tighten this for published libraries, because consumers inherit the risk, and loosen it for short-lived internal apps. Enforcement matters more than wording: an allow-list in parser and lint config, so nothing arrives by accident. Strictness costs delay and workarounds, so I would review the list on a cadence and retire exceptions at Stage 4.

go deeper

for a junior

Recall that a team can decide which proposals it uses, and that the stage of a proposal says how settled its design is. Know that syntax from unfinished proposals needs a build step on older targets.

for a middle

Explain why syntax is costlier than an API to adopt early: it spreads through files and cannot sit behind a wrapper. Be able to say what a transform in the build is tying the source to.

for a senior

Argue a specific case within the rule: is this exception worth it, who owns it, what is the exit? Back it with a precedent such as class fields changing semantics at standardization.

for a principal

Own the rule, including its costs. Separate spec risk from runtime risk, scale the bar by blast radius, enforce it in tooling, and revisit it, since a rule nobody reviews becomes either a loophole or a wall.

## Why this needs a rule at all **TC39** is the committee that moves JavaScript features through stages, ending at **Stage 4**, where a proposal is complete and bound for the ECMAScript standard. Pre-stage-4 **syntax** is the expensive case: it spreads through source files, cannot be wrapped behind a module, and on older targets depends on a transpiler, a build tool that rewrites newer syntax into older. Decided one pull request at a time, this produces a codebase whose dialect nobody chose. A standing rule moves the decision from whoever wanted the feature that week to whoever will pay for it later. There is no single correct rule. A reasonable lead weighs the same factors and lands differently depending on the product, so an interview answer should expose the reasoning. ## Two risks, one stage number - **Spec risk**: the design changes. The stage measures this. Stage 2 "may still change significantly", Stage 2.7 changes only on evidence from testing or usage, Stage 3 expects no changes but allows necessary ones, and Stage 4 makes no further changes to the proposal. - **Runtime risk**: your targets cannot run it. The stage does not measure this. A Stage 4 feature can be missing from a browser you support, while a Stage 3 feature can be running in all of them. A rule keyed only on the stage handles the first risk and ignores the second. Require both answers. ## A workable default | Stage of the syntax | Default for an application | Default for a published library | |---|---|---| | Stage 4 | Allowed once targets or the build handle it | Allowed once consumers' likely targets are covered | | Stage 3 | Recorded exception, with owner and exit plan | Avoid in anything consumers compile or see | | Stage 2.7 | Not in shipped code | Not in shipped code | | Stage 2 and below | Not in shipped code; experiments only | Not in shipped code | The line at Stage 3 has evidence behind it. Stage 3 is the point where the committee recommends implementation, and Stage 2's experimental polyfills are explicitly described as "not for production use". ## What an exception must contain 1. **The benefit**, stated against waiting: what do we gain that a helper or the older form would not give us, and for how long? 2. **The owner**, a named person who watches the proposal and acts when it moves. 3. **The exit**, including how use sites will be found and migrated, usually a codemod, a script that rewrites source mechanically, and a test suite that pins the behaviour. 4. **The removal trigger**, for example dropping the transform when the proposal reaches Stage 4 and all targets ship it natively. ## What you are weighing - **Blast radius.** A short-lived internal tool can absorb a rewrite. A long-lived product costs more, and a public library hands the problem to people you cannot reach. - **Migration cost.** Syntax spread over thousands of files is not one edit. Class fields are the documented warning: most transpilers compiled them with assignment semantics before the standard settled on define semantics, and that caused subtle bugs after standardization. Decorators are a second one, where an early form and the standard form differ at runtime and code bases have had to carry the difference for years. - **Tool coupling.** Pre-stage-4 syntax ties the source to a particular transformer. That constrains which tools you can adopt, because alternatives may not parse it. - **The cost of strictness.** A blanket ban is simple to run, but teams then build their own abstractions, and they lose time on things a stable proposal would have given them. Some teams accept that price, and for a library it may be right. - **Reversibility.** Prefer adoption paths you can undo. Where a stable alternative exists, the bar for an exception should be high. ## Making it stick A rule that lives only in a document decays. Encode it instead. - Keep an allow-list of permitted proposals in parser and lint configuration, so unapproved syntax fails in CI. - Review that list on a schedule, because proposals move and exceptions should retire. - Keep a record of each exception beside the code, so the next lead can see why it exists. - Treat existing stage-2-era syntax as debt: freeze new uses, pin behaviour with tests, then migrate.

  • When is a Stage-4-only rule too strict?
    When a stable Stage 3 feature removes a real class of bugs, and a short-lived application can absorb a change. Then the ban costs more than the risk, because the team builds its own abstractions and migrates to the standard form later anyway. For a public library the strict rule is often right.
  • How do you handle pre-stage-4 syntax already spread through a large codebase?
    Treat it as debt with a plan. Freeze new uses in lint, write tests that pin the behaviour relied on, and track the proposal. Migrate by codemod when the standard form is settled, then remove the transform. Comparing rewrite cost with the risk of staying sets the timing.
  • Why hold a published library to a stricter rule than an application?
    An application's team can redeploy, so a semantic change is its own cost. A library's consumers inherit its choices: they may need a matching transform, and a later fix depends on their upgrades. The people paying for the risk took no part in the decision, so the bar goes up.

  • Stage 4 alone means a feature is safe for all of our users.
  • A policy only needs writing down; the tooling can stay permissive.
  • If a transformer enables a proposal by default, the team has effectively approved it.
  • Stage 3 exceptions need no exit plan, since changes are not expected.
  • Applications and published libraries carry the same adoption risk.
  • Migrating pre-stage-4 syntax later is always a trivial find and replace.