Skip to content

API snapshots: Fix indentation of wrapped declarations - #1936

Open
robhogan wants to merge 1 commit into
mainfrom
pr1936
Open

robhogan wants to merge 1 commit into
mainfrom
pr1936

Conversation

@robhogan

@robhogan robhogan commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

Summary:
As spotted by @vzaidman in #1892 (comment) - any declaration that wraps across lines loses its indentation in API.md snapshots, e.g.:

export type GetTransformOptions = (
entryPoints: ReadonlyArray<string>,
options: GetTransformOptionsOpts,
getDependenciesOf: (absoluteFilePath: string) => Promise<Array<string>>,
) => Promise<Partial<ExtraTransformOptions>>;

This diff runs the report's code block through Prettier after cleaning, with the same options as the .d.ts generator, so declarations wrap and indent the same way they do in the published d.ts.

Changelog: Internal

Summary:
As spotted by @vzaidman in #1892 (comment) - any declaration that wraps across lines loses its indentation in `API.md` snapshots, e.g.:

```ts
export type GetTransformOptions = (
entryPoints: ReadonlyArray<string>,
options: GetTransformOptionsOpts,
getDependenciesOf: (absoluteFilePath: string) => Promise<Array<string>>,
) => Promise<Partial<ExtraTransformOptions>>;
```

The `.d.ts` input is correctly formatted, but API Extractor's `ApiReportGenerator` writes with `trimLeadingSpaces` enabled and re-indents only between `{` and `}`, so parameter lists, type arguments and union continuations all end up flush-left (or mis-indented, when nested inside braces). There's no config option for this.

This diff runs the report's code block through Prettier after cleaning, with the same options as the `.d.ts` generator (repo config, `printWidth: 200`), so declarations wrap and indent the same way they do in the published definitions. The snapshot churn is a one-off: 4-space -> 2-space indentation, `import type {X}` bracket spacing, and the indentation fixes themselves - no API changes.

Changelog: Internal
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 16, 2026
@robhogan
robhogan marked this pull request as ready for review September 16, 2026 21:51
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant