Summary
oxfmt panics in sort_imports when a file contains a floating /** … */ JSDoc block (separated from the first import by a blank line) followed by two or more import statements.
Same panic site as #22354, but a distinct trigger that isn't covered by the fix in #22369 (which is shipped in 0.50.0).
Versions / env
oxfmt 0.50.0 (released 2026-05-15)
- macOS 25.4.0, arm64, Node 24.15.0
Minimal repro
repro.ts — four lines is enough:
/** jsdoc */
import * as React from "react";
import { foo } from "bar";
$ oxfmt --threads 1 repro.ts
thread '<unnamed>' panicked at crates/oxc_formatter/src/ir_transform/sort_imports/source_line.rs:139:32:
`ImportDeclaration` must have a source
Bisected trigger
The panic requires all three:
| Condition |
Panics? |
/** jsdoc */ + blank + import a + import b |
yes |
/* jsdoc */ (single *) + blank + import a + import b |
no |
// jsdoc line comment + blank + import a + import b |
no |
/** jsdoc */ + import a (attached, no blank) + blank + import b |
no |
/** jsdoc */ + blank + single import a only |
no |
So: JSDoc-style block comment + detached from the first import by a blank line + ≥ 2 imports.
The JSDoc body content doesn't matter (single-line /** x */ is enough). Multiline JSDoc with @see etc. behaves the same — that's just how I originally hit it in a real file.
Expected
Format without panicking — concretely, every ImportDeclaration reaching sort_imports/source_line.rs:139 should have its source set.
Related
Summary
oxfmtpanics insort_importswhen a file contains a floating/** … */JSDoc block (separated from the first import by a blank line) followed by two or more import statements.Same panic site as #22354, but a distinct trigger that isn't covered by the fix in #22369 (which is shipped in 0.50.0).
Versions / env
oxfmt0.50.0 (released 2026-05-15)Minimal repro
repro.ts— four lines is enough:Bisected trigger
The panic requires all three:
/** jsdoc */+ blank +import a+import b/* jsdoc */(single*) + blank +import a+import b// jsdocline comment + blank +import a+import b/** jsdoc */+import a(attached, no blank) + blank +import b/** jsdoc */+ blank + singleimport aonlySo: JSDoc-style block comment + detached from the first import by a blank line + ≥ 2 imports.
The JSDoc body content doesn't matter (single-line
/** x */is enough). Multiline JSDoc with@seeetc. behaves the same — that's just how I originally hit it in a real file.Expected
Format without panicking — concretely, every
ImportDeclarationreachingsort_imports/source_line.rs:139should have itssourceset.Related
ImportDeclarations in a run #22079, as noted in formatter: Ignore directive before import causes panic #22354.