Improve preservation of doc comments after type translation#57389
Open
huntie wants to merge 1 commit into
Open
Improve preservation of doc comments after type translation#57389huntie wants to merge 1 commit into
huntie wants to merge 1 commit into
Conversation
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
|
@huntie has exported this pull request. If you are a Meta employee, you can view the originating Diff in D109316361. |
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:
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
componentsyntax), meaning many root APIs (View,ScrollView,Pressable, and others) showed no documentation on hover.This diff extends the existing
reattachDocCommentstransform to handle doc comment repositioning (suitable for the TS lang server) from a greater set of source positions:.displayNameassignmentdeclare const/declare export default typeof XstubImpact
(With the source code JSDoc improvements earlier in this stack.)
Changelog:
[General][Fixed] - Preserve doc comments on root API symbols in the generated TypeScript types
Differential Revision: D109316361