Stop checking in generated .d.ts; keep only public API snapshots (#1801) - #1801
Open
robhogan wants to merge 2 commits into
Open
Stop checking in generated .d.ts; keep only public API snapshots (#1801)#1801robhogan wants to merge 2 commits into
robhogan wants to merge 2 commits into
Conversation
Summary: Adds Microsoft's `microsoft/api-extractor` (7.52.2) as a Metro dev dependency and builds a system that captures a public API snapshot for each OSS package based on its `package.json` `exports` entry points. - `scripts/generateApiSnapshots.js` enumerates every package, derives the public entry points from `exports` (skipping `./package.json`, wildcard subpaths like `./private/*`, and entries with no generated `.d.ts`), and runs API Extractor over each package's generated TypeScript definitions to produce a public API report. - The report is written to `API.md` at each package root (secondary entry points are suffixed, e.g. `API-<subpath>.md`). - The report is post-processed to drop annotations that are pure noise for Metro (whose surface is documented by Flow types, not TSDoc): the release-tag comments (`// @public` etc.), `(undocumented)` markers, and the "(No packageDocumentation comment...)" notice. Meaningful modifiers such as `deprecated` are preserved. API Extractor exposes no config to suppress these (they are hardcoded in its ApiReportGenerator), so this is done in `cleanReport`. - Wired into `js1 build metro-ts-defs` (runs after TS-def generation) and exposed to OSS as `yarn run build-api-snapshots`. - `scripts/__tests__/api-snapshots-sync-test.js` fails if a committed snapshot is stale, mirroring the existing TS-defs sync test. - `flow-typed/microsoft-api-extractor.js` provides a local libdef for the subset of the API Extractor API used here (Flow does not resolve `node_modules`); registered in `xplat/js/.flowconfig` `[libs]`. - `tsconfig.api-extractor.json` mirrors the project tsconfig plus the `dom` lib so API Extractor resolves ambient globals. 14 snapshots are generated; `metro-runtime` runtime-only subpaths, `metro-babel-register`, and the CLI-only `metro-symbolicate` are skipped (no exported type surface). Differential Revision: https://www.internalfb.com/D112750747
Contributor
|
@robhogan has exported this pull request. If you are a Meta employee, you can view the originating Diff in D112750746. |
Summary: Pull Request resolved: #1801 Makes the per-package TypeScript definition files (`packages/*/types/*.d.ts`) build artefacts instead of checked-in source, now that `microsoft/api-extractor` gives us snapshots of public APIs. Note - `.d.ts` files are still emitted for every module at build time and published to npm. The main benefit of this is to reduce developer friction - previously, any change to a module's API would require rebuilding TS definitions. Now, a manual step is only required when changing the *public* API, which is both much less common and should always be done intentionally. Changelog: Internal Reviewed By: huntie Differential Revision: D112750746
robhogan
force-pushed
the
export-D112750746
branch
from
July 28, 2026 13:44
a941eea to
b520d75
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Makes the per-package TypeScript definition files (
packages/*/types/*.d.ts) build artefacts instead of checked-in source, now thatmicrosoft/api-extractorgives us snapshots of public APIs.Note -
.d.tsfiles are still emitted for every module at build time and published to npm.The main benefit of this is to reduce developer friction - previously, any change to a module's API would require rebuilding TS definitions. Now, a manual step is only required when changing the public API, which is both much less common and should always be done intentionally.
Changelog: Internal
Reviewed By: huntie
Differential Revision: D112750746