Why doesn’t TypeScript infer the most narrow type declaration?

Why doesn’t TypeScript emit "a" | "b" for the type of test2?

// index.ts
export const test1 = true ? ('a' as const) : ('b' as const);
export const test2 = true ? 'a' : 'b';
// index.d.ts
export declare const test1: "a" | "b";
export declare const test2: string;
// tsconfig.json
{
  "compilerOptions": {
    "composite": true,
    "emitDeclarationOnly": true,
  }
}

StackBlitz Link