#26240·oxc

formatter/js: not idempotent on functions with long inline object return types (wraps params on pass 1, joins on pass 2)

Author: tobias-huiCreated Sep 2, 2026Updated Sep 29, 2026
LabelsA-formatter-outputF-lang-js

oxfmt version

0.66.0 (reproduces with default config, no .oxfmtrc.json)

Summary

Formatting a function whose return type is a long inline object literal type is not idempotent: pass 1 wraps the parameter list, pass 2 joins it again. Two passes are needed to reach the fixed point.

Minimal reproduction

typescript
type BingConnectionRow = { id: number };
type BingCredentialBundle = { apiKey: string | null };

async function connectionAccess(row: BingConnectionRow): Promise<{ row: BingConnectionRow; bundle: BingCredentialBundle; accessToken: string; authorizationVersion: number }> {
  return null as never;
}

Steps

bash
oxfmt repro.ts   # pass 1
cp repro.ts pass1.ts
oxfmt repro.ts   # pass 2
diff pass1.ts repro.ts

Actual behavior

Pass 1 output:

typescript
async function connectionAccess(
  row: BingConnectionRow,
): Promise<{
  row: BingConnectionRow;
  bundle: BingCredentialBundle;
  accessToken: string;
  authorizationVersion: number;
}> {

Pass 2 joins the parameters back (pass1 != pass2):

typescript
async function connectionAccess(row: BingConnectionRow): Promise<{
  row: BingConnectionRow;
  ...

Pass 3 is stable, so the fixed point exists but is not reached in one pass.

Expected behavior

oxfmt(oxfmt(x)) == oxfmt(x) after a single pass — pass 1 should already emit the pass-2 form (the joined parameter line fits within the print width).

Impact

oxfmt --check in CI disagrees with what a single local oxfmt run produces, so a file formatted once locally can fail CI. Observed on 15 files in a real codebase (functions returning Promise<{ ...multi-line object type... }>). Workaround: run oxfmt twice.