From 1575ae0e3fbd9a329f90690eacb54128a6fafe8f Mon Sep 17 00:00:00 2001 From: Eli White Date: Mon, 26 Jan 2026 14:04:07 -0800 Subject: [PATCH] Rename TypeInformationComparisonError fields to match TypeAnnotationComparisonError (#55302) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/55302 Rename newerType/olderType to newerAnnotation/olderAnnotation in TypeInformationComparisonError to be consistent with TypeAnnotationComparisonError. This allows code that handles both error types to access annotation fields uniformly without checking error type first. Changelog: [Internal] Reviewed By: makovkastar Differential Revision: D91275947 fbshipit-source-id: 03a7a4aa521afea5bc8f21d6ab49309ad449b977 --- .../src/ComparisonResult.js | 12 ++++++------ .../src/ErrorFormatting.js | 13 +------------ 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/packages/react-native-compatibility-check/src/ComparisonResult.js b/packages/react-native-compatibility-check/src/ComparisonResult.js index a6a296dcb15..b131979a0b9 100644 --- a/packages/react-native-compatibility-check/src/ComparisonResult.js +++ b/packages/react-native-compatibility-check/src/ComparisonResult.js @@ -24,8 +24,8 @@ type TypeAnnotationComparisonError = { type TypeInformationComparisonError = { type: 'TypeInformationComparisonError', message: string, - newerType: CompleteTypeAnnotation, - olderType: CompleteTypeAnnotation, + newerAnnotation: CompleteTypeAnnotation, + olderAnnotation: CompleteTypeAnnotation, previousError?: TypeComparisonError, }; type PropertyComparisonError = { @@ -179,15 +179,15 @@ export function makeError(error: TypeComparisonError): ComparisonResult { export function typeInformationComparisonError( message: string, - newerType: CompleteTypeAnnotation, - olderType: CompleteTypeAnnotation, + newerAnnotation: CompleteTypeAnnotation, + olderAnnotation: CompleteTypeAnnotation, previousError?: TypeComparisonError, ): TypeComparisonError { return { type: 'TypeInformationComparisonError', message, - newerType, - olderType, + newerAnnotation, + olderAnnotation, previousError, }; } diff --git a/packages/react-native-compatibility-check/src/ErrorFormatting.js b/packages/react-native-compatibility-check/src/ErrorFormatting.js index 6e0b6f2870e..39df6aad8fc 100644 --- a/packages/react-native-compatibility-check/src/ErrorFormatting.js +++ b/packages/react-native-compatibility-check/src/ErrorFormatting.js @@ -54,6 +54,7 @@ export function formatErrorMessage( ); return error.message + formattedPositionalChanges.join(''); case 'TypeAnnotationComparisonError': + case 'TypeInformationComparisonError': const previousError = error.previousError; return ( @@ -70,18 +71,6 @@ export function formatErrorMessage( formatErrorMessage(previousError, indent + 2) : '') ); - case 'TypeInformationComparisonError': - // I'm not sure that this error type is possible with the codegen - - return ( - error.message + - indentedLineStart(indent + 1) + - '-- new: ' + - formatTypeAnnotation(error.newerType) + - indentedLineStart(indent + 1) + - '-- old: ' + - formatTypeAnnotation(error.olderType) - ); case 'MemberComparisonError': const formattedMembers = error.mismatchedMembers.map( individualMemberError =>