Development How-to

TypeScript 7.1 rejects conditional types that 7.0 accepts: three fixes, and only one keeps the meaning

A new check on distributed type parameters turns silent constraint holes into errors. Pin the old behaviour in a type test first, then let the agent fix the compile errors.

A white cube split by horizontal scanline tears, with violet colour-channel offsets along the tears.

The TypeScript 7.1 Beta compiler has a new error that 7.0.2 never raised, and it lands in exactly the kind of code an agent writes when it’s asked for a clever generic: a conditional type that checks one parameter against another, then passes both into a helper with a constraint. Nothing in the file changed. The compiler just got stricter about what it was already supposed to check.

The 7.1 Beta, announced on 20 October 2026, lists it as a change that can add errors to existing code. The cause is microsoft/TypeScript#63708 , which was fixed in PR #64237 and merged on 16 September 2026. The fix is easy. Keeping the type’s behaviour while you do it is the part that needs a test, because two of the three obvious fixes quietly change what the type means.

This piece reproduces the error, pins the behaviour in a type test while still on 7.0, and gives an agent a prompt that can’t talk its way past the test. It works with any coding agent that can read files and run a shell, and the test and the compiler are the judges, not the agent.

The error, reproduced

Here’s the example from the announcement, in a file of its own:

// shapes.ts
type Show<A extends number, B extends A> = `${A} vs ${B}`;
type Issue<A extends number, B extends A> = A extends B ? never : Show<A, B>;

Issue returns never when A is assignable to B, and otherwise formats the pair. Show requires B extends A, which Issue also declares, so it looks fine. On 7.0.2 it is fine, in the sense that the compiler says nothing.

With the two compilers side by side (the setup is below), 7.1.0-beta says:

shapes.ts(3,75): error TS2344: Type 'B' does not satisfy the constraint 'A'.
  'B' is only assignable to the non-distributed 'A', but 'A' has been distributed here.

Why it was a hole: Issue is a distributive conditional type, so when A is a union the check runs once per member of A. In the false branch, A stands for a single member, and B extends A was only ever promised for the whole union. The old compiler didn’t re-check the constraint per member. Per the pull request, a distributed parameter is now treated as a subtype of its non-distributed form, so a constraint that holds for the whole doesn’t automatically hold for the part. Hovering such a parameter in the language service shows (distributed).

In practice, the old compiler let Issue<0 | 1, 0 | 1> produce Show<0, 1> and Show<1, 0>, pairs that break the declared B extends A for the member being checked. That’s the case the issue reported.

Step 1: get both compilers installed

Install 7.1 as the project’s compiler and keep 7.0.2 under an alias, so every check can be run twice:

npm install -D typescript@beta typescript7_0@npm:typescript@7.0.2
npx tsc -v
node_modules/typescript7_0/bin/tsc -v
Version 7.1.0-beta
Version 7.0.2

The same alias trick is used in the TypeScript 7 migration post , which also covers the larger 6-to-7 move. Don’t push the beta to your main branch’s lockfile on the strength of this article: it’s a beta, and the announcement gives no dates beyond a release candidate “about a month” after it.

Run the compiler on a file by itself, with config ignored so the flags apply:

npx tsc --ignoreConfig --noEmit --strict --target es2022 --types "" shapes.ts
node_modules/typescript7_0/bin/tsc --ignoreConfig --noEmit --strict --target es2022 --types "" shapes.ts

The first prints the error above. The second prints nothing. That asymmetry is your inventory: every file where the beta errors and 7.0.2 doesn’t is a type the new check has opinions about. On a real repository, run both against the full project and diff the output, which gives you the list of files the agent is allowed to touch.

Step 2: pin the behaviour before anyone edits

An agent will make the error go away. It won’t necessarily preserve what the type did, and a type that now says something slightly different doesn’t fail to compile. It fails three modules away, as a never where a string used to be.

So write the behaviour down while the original still compiles on 7.0.2. Vitest 5.1.0 can assert on types with expectTypeOf in a .test-d.ts file. Its CLI describes typechecking as experimental, so pin the Vitest version:

// shapes.test-d.ts
import { expectTypeOf, test } from "vitest";
import type { Issue } from "./shapes";

test("Issue keeps the pairs that differ", () => {
  expectTypeOf<Issue<1 | 2, 1>>().toEqualTypeOf<"2 vs 1">();
  expectTypeOf<Issue<1, 1>>().toBeNever();
});
// vitest.config.ts
import { defineConfig } from "vitest/config";

export default defineConfig({
  test: {
    typecheck: {
      enabled: true,
      include: ["**/*.test-d.ts"],
    },
  },
});

The expected values aren’t guesses. Record them from the old compiler: on 7.0.2, Issue<1 | 2, 1> resolves to "2 vs 1", because the 1 member satisfies A extends B and becomes never, and the 2 member survives. Run the suite on 7.0.2:

 Test Files  1 passed (1)
      Tests  1 passed (1)
Type Errors  no errors

Switch to the beta and run it again without touching shapes.ts. Vitest still reports the test as passed, but it also surfaces the compiler error as an unhandled source error and exits with code 1:

TypeCheckError: Type 'B' does not satisfy the constraint 'A'.
  'B' is only assignable to the non-distributed 'A', but 'A' has been distributed here.
 ❯ shapes.ts:2:82

That exit code is the gate. If your CI treats a green test count as success and ignores the exit status, it will wave this through. Check the exit status, not the summary line.

Step 3: three fixes, one that survives

The announcement offers two ways out: remove the original constraint if it isn’t needed, or add conditional checks that prove it. A third is the handbook’s way to stop distribution, wrapping each side of extends in square brackets. Here are all three, each run against the test above on 7.1.0-beta.

Remove the constraint on Show (and on Issue), since B extends A was only there to relate two numbers that don’t need relating:

type Show<A extends number, B extends number> = `${A} vs ${B}`;
type Issue<A extends number, B extends number> = A extends B ? never : Show<A, B>;

Prove the constraint in the branch:

type Show<A extends number, B extends A> = `${A} vs ${B}`;
type Issue<A extends number, B extends A> =
  A extends B ? never : B extends A ? Show<A, B> : never;

Stop distributing:

type Show<A extends number, B extends A> = `${A} vs ${B}`;
type Issue<A extends number, B extends A> = [A] extends [B] ? never : Show<A, B>;

All three compile on 7.1.0-beta. Only the first passes the test:

FixCompiles on 7.1Issue<1 | 2, 1>Test
Drop the constraintyes"2 vs 1"passes
Re-check in the branchyesneverfails
Wrap in tuplesyes"1 vs 1" | "2 vs 1"fails

The second one fails because, once distributed, the member 2 doesn’t satisfy B extends A with B being 1, so the inner check sends it to never. The test reports it this way:

TypeCheckError: Type '"2 vs 1"' does not satisfy the constraint
  '"Expected literal string 2 vs 1, Actual never"'.

The third fails because wrapping turns off distribution entirely: [1 | 2] extends [1] is false, so the whole union flows into Show, and you get both "1 vs 1" and "2 vs 1". Sometimes that’s what a type should do. Here it isn’t, and a compiler that’s happy can’t tell you so.

Fix one is the right call for this type, but not as a general rule. Dropping a constraint is fine when nothing downstream relies on it, and a type test is how you find out. When a constraint is doing real work (it narrows a template literal or an indexed access, say), the in-branch check is usually the one to reach for, with expected values that account for the narrowing.

Step 4: let the agent do the editing

Give the agent the failing output, the test and the rules of the game. This prompt is deliberately dull:

TypeScript 7.1.0-beta raises TS2344 on the types listed below. They compile on 7.0.2.
Fix each error in the file named, and nothing else.

Rules:
- Do not edit any *.test-d.ts file. They record the behaviour on 7.0.2.
- Prefer removing an unnecessary constraint. If a constraint is needed, add an
  in-branch check. Do not wrap type parameters in tuples unless the test still passes.
- After each change run: npx vitest run
  A run is green only if the exit status is 0.
- If a fix changes what a type resolves to, stop and tell me which type and why.

Files: <paste the list from the two-compiler diff>

Any agent that can read files and run a shell can follow it, since the instructions only use npx vitest run and the exit status. The rule about test files matters: an agent that finds a failing test and a passing way out will sometimes update the expected value, and then the baseline stops being a baseline. Run git diff --stat -- '*.test-d.ts' before accepting the change. It should print nothing.

When the check finds nothing, and when it finds too much

A type with no constraint tying two parameters together never trips this. If the two-compiler diff comes back empty for your own source, there’s nothing to fix and no need for the tests above. The error needs a distributive conditional type with a constrained second parameter used in a branch, which is a narrower shape than “uses generics”.

Two things sit outside your control. First, errors can come from declaration files in dependencies. The pull request’s own test runs against external projects reported new errors, including in type-fest and Inquirer.js test configurations, as observed changes rather than guidance. If a dependency’s .d.ts is the source, skipLibCheck hides it, and the real fix is an upgrade or a report upstream. Second, the 7.1 announcement lists other changes that can add errors in the same release (generated DOM types among them), so a diff of compiler output will mix causes. Filter on TS2344 and the distributed wording before handing anything to an agent.

Last, the type test only protects behaviours you thought to write down. Pick the inputs that matter: a single member, a union, a member that matches and one that doesn’t, and never. For Issue, the union case was the one that caught both wrong fixes.

First 15 minutes

Install the beta beside 7.0.2 as above. Run both compilers over the project and diff the output. If the beta adds a TS2344 with the “distributed” note, copy the failing type into a .test-d.ts file, record what it resolves to on 7.0.2, and only then hand it to an agent with the prompt above.