Skip to content

Improve preservation of doc comments after type translation#57389

Open
huntie wants to merge 1 commit into
react:mainfrom
huntie:export-D109316361
Open

Improve preservation of doc comments after type translation#57389
huntie wants to merge 1 commit into
react:mainfrom
huntie:export-D109316361

Conversation

@huntie

@huntie huntie commented Jun 30, 2026

Copy link
Copy Markdown
Member

Summary:
Context

Strict TypeScript API readiness: High quality inline docs should reach users via TypeScript in their IDEs.

This diff

Prior iterations of our Flow → TS translation stack dropped doc comments for default-exported values, and/or identifiers which change shape after type transformation (e.g. Flow component syntax), meaning many root APIs (View, ScrollView, Pressable, and others) showed no documentation on hover.

This diff extends the existing reattachDocComments transform to handle doc comment repositioning (suitable for the TS lang server) from a greater set of source positions:

  • the exported declaration
  • a .displayName assignment
  • a HOC-wrapped inner component
  • a renamed wrapper's public-named component
  • a declare const / declare export default typeof X stub

Impact

(With the source code JSDoc improvements earlier in this stack.)

Before (legacy types) After (Strict API)
image image
⚠️ No inline docs for many symbols ✅ New, detailed inline docs reach the TS server 🎉

Changelog:
[General][Fixed] - Preserve doc comments on root API symbols in the generated TypeScript types

Differential Revision: D109316361

Summary:
**Context**

Strict TypeScript API readiness: High quality inline docs should reach users via TypeScript in their IDEs.

**This diff**

Prior iterations of our Flow → TS translation stack dropped doc comments for default-exported values, and/or identifiers which change shape after type transformation (e.g. Flow `component` syntax), meaning many root APIs (`View`, `ScrollView`, `Pressable`, and others) showed no documentation on hover.

This diff extends the existing `reattachDocComments` transform to handle doc comment repositioning (suitable for the TS lang server) from a greater set of source positions:

- the exported declaration
- a `.displayName` assignment
- a HOC-wrapped inner component
- a renamed wrapper's public-named component
- a `declare const` / `declare export default typeof X` stub

**Impact**

(With the source code JSDoc improvements earlier in this stack.)

| Before (legacy types) | After (Strict API) |
| -- |
|  {F1991869487}  | {F1991869472}  |
| ⚠️ No inline docs for many symbols | ✅ New, detailed inline docs reach the TS server 🎉 |

Changelog:  
[General][Fixed] - Preserve doc comments on root API symbols in the generated TypeScript types

Differential Revision: D109316361
@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 Jun 30, 2026
@meta-codesync

meta-codesync Bot commented Jun 30, 2026

Copy link
Copy Markdown

@huntie has exported this pull request. If you are a Meta employee, you can view the originating Diff in D109316361.

@huntie huntie changed the title Reattach default-export doc comments Improve preservation of doc comments after type translation Jun 30, 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. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant