Skip to content

Incorrect JSDoc indentation for object property comments #168

@aryaemami59

Description

@aryaemami59

Describe the bug

When emitting TypeScript declarations, JSDoc comments attached to object properties (in either interface or type declarations) are indented incorrectly.

Given the following source:

export interface Options {
  /**
   * interface member
   */
  foo: string
}

The generated output is:

interface Options {
  /**
       * interface member
       */
  foo: string;
}

export { type Opttions };

Notice that the leading * inside the JSDoc block is over-indented, which breaks formatting and readability.

Expected output

interface Options {
  /**
   * interface member
   */
  foo: string
}

export { type Opttions };
Diff
interface Options {
  /**
-       * interface member
-      */
+   * interface member
+   */
  foo: string;
}

Reproduction

https://github.com/sxzz/rolldown-plugin-dts/blob/28d8e65455d1b18ca0376812f445083543b2643c/tests/__snapshots__/tsc.test.ts.snap#L365-L370C2

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (24) x64 AMD Ryzen 9 5900X 12-Core Processor            
    Memory: 1.01 GB / 31.91 GB
  Binaries:
    Node: 24.13.0 - C:\Program Files\nodejs\node.EXE
    npm: 11.7.0 - C:\Program Files\nodejs\npm.CMD
    pnpm: 10.28.0 - C:\Program Files\nodejs\pnpm.CMD
  Browsers:
    Chrome: 143.0.7499.193
    Edge: Chromium (140.0.3485.54)
    Firefox: 146.0.1 - C:\Program Files\Mozilla Firefox\firefox.exe
    Internet Explorer: 11.0.22621.3527

Used Package Manager

npm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

Contributions

  • I am willing to submit a PR to fix this issue
  • I am willing to submit a PR with failing tests (actually just go ahead and do it, thanks!)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions