Fix hash generation for declare const types in API snapshot #54818#54822
Closed
emily8rown wants to merge 1 commit intofacebook:mainfrom
Closed
Fix hash generation for declare const types in API snapshot #54818#54822emily8rown wants to merge 1 commit intofacebook:mainfrom
emily8rown wants to merge 1 commit intofacebook:mainfrom
Conversation
|
@emily8rown has exported this pull request. If you are a Meta employee, you can view the originating Diff in D88653322. |
Collaborator
|
…54818 Summary: Updates hash generation in `versionExportedApis.js` to track changes to `declare const` type declarations like `AccessibilityInfo_default`. Previously, changes to APIs (e.g., `AccessibilityInfo`) would not always update their hashes in `ReactNativeApi.d.ts`, causing the breaking change detection to miss actual API changes. Three issues prevented proper hash tracking: 1. **`VariableDeclaration` types weren't tracked** - `declare const X: {...}` was not in the list of tracked declaration types 2. **Duplicate declarations caused overwrites** - `declare type X = typeof X` would overwrite `declare const X: typeof X_default` in the declarations map, losing the dependency on `X_default` 3. **`typeof X` queries weren't extracting dependencies** - references via `typeof` weren't being added to the dependency graph ## Fix - Add `t.isVariableDeclaration(node)` to tracked types with proper name extraction - Prevent overwriting existing declarations (first declaration wins) - Handle `TSTypeQuery` nodes to extract `typeof X` dependencies ### Note on Hash Changes This PR causes many hashes to change, even for types that haven't been modified. This is expected because the hash computation now includes `declare const` dependencies that were previously ignored. **Before:** `AccessibilityInfo` hash only included `declare type AccessibilityInfo = typeof AccessibilityInfo` (self-reference) **After:** Hash now includes `declare const AccessibilityInfo: typeof AccessibilityInfo_default` + the full `AccessibilityInfo_default` type ## Changelog: [GENERAL] [FIXED] - hash generation includes `declare const` types in API snapshot Differential Revision: D88653322
9d6b953 to
7a68383
Compare
Collaborator
|
This pull request was successfully merged by @emily8rown in c36665f When will my fix make it into a release? | How to file a pick request? |
|
This pull request has been merged in c36665f. |
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:
Fixes hash generation in
versionExportedApis.jsto properly track changes todeclare consttype declarations likeAccessibilityInfo_default.Previously, changes to APIs (e.g.,
AccessibilityInfo) would not always update their hashes inReactNativeApi.d.ts, causing the breaking change detection to miss actual API changes.Problem
Three issues prevented proper hash tracking:
VariableDeclarationtypes weren't tracked -declare const X: {...}was not in the list of tracked declaration typesdeclare type X = typeof Xwould overwritedeclare const X: typeof X_defaultin the declarations map, losing the dependency onX_defaulttypeof Xqueries weren't extracting dependencies - references viatypeofweren't being added to the dependency graphFix
t.isVariableDeclaration(node)to tracked types with proper name extractionTSTypeQuerynodes to extracttypeof XdependenciesNote on Hash Changes
This PR causes many hashes to change, even for types that haven't been modified. This is expected because the hash computation now includes
declare constdependencies that were previously ignored.Before:
AccessibilityInfohash only includeddeclare type AccessibilityInfo = typeof AccessibilityInfo(self-reference)After: Hash now includes
declare const AccessibilityInfo: typeof AccessibilityInfo_default+ the fullAccessibilityInfo_defaulttypeThis is a one-time recalibration. Going forward, changes to these types will be properly detected.
Changelog:
[GENERAL] [FIXED] - Fix hash generation for
declare consttypes in API snapshotDifferential Revision: D88653322