@react-native/compatibility-check 0.0.0 → 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,137 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ * @format
9
+ */
10
+
11
+ import type {
12
+ PropertiesComparisonResult,
13
+ TypeComparisonError,
14
+ } from "./ComparisonResult";
15
+ import type { CompleteTypeAnnotation } from "@react-native/codegen/src/CodegenSchema";
16
+ export type ErrorCode =
17
+ | "addedProps"
18
+ | "removedProps"
19
+ | "changedParams"
20
+ | "incompatibleTypes"
21
+ | "requiredProps"
22
+ | "optionalProps"
23
+ | "nonNullableOfNull"
24
+ | "nullableOfNonNull"
25
+ | "removedUnionCases"
26
+ | "addedUnionCases"
27
+ | "addedEnumCases"
28
+ | "removedEnumCases"
29
+ | "removedIntersectCases"
30
+ | "addedIntersectCases"
31
+ | "removedModule"
32
+ | "removedComponent";
33
+ export type TypeStore = {
34
+ typeName: string;
35
+ typeInformation: CompleteTypeAnnotation;
36
+ };
37
+ export type ObjectTypeChangeStore = {
38
+ typeName: string;
39
+ newType: CompleteTypeAnnotation;
40
+ oldType: CompleteTypeAnnotation;
41
+ propertyChange: PropertiesComparisonResult;
42
+ };
43
+ export type ErrorStore = {
44
+ typeName: string;
45
+ errorCode: ErrorCode;
46
+ errorInformation: TypeComparisonError;
47
+ };
48
+ export type FormattedErrorStore = { message: string; errorCode: ErrorCode };
49
+ export type NativeSpecErrorStore = {
50
+ nativeSpecName: string;
51
+ omitted: boolean;
52
+ errorCode: ErrorCode;
53
+ errorInformation?: TypeComparisonError;
54
+ changeInformation?: DiffSet;
55
+ };
56
+ export type ExportableNativeSpecErrorStore = {
57
+ nativeSpecName: string;
58
+ omitted: boolean;
59
+ errorCode: ErrorCode;
60
+ errorInformation?: TypeComparisonError;
61
+ changeInformation?: ExportableDiffSet;
62
+ };
63
+ export type DiffSet = {
64
+ newTypes: Set<TypeStore>;
65
+ deprecatedTypes: Set<TypeStore>;
66
+ objectTypeChanges: Set<ObjectTypeChangeStore>;
67
+ incompatibleChanges: Set<ErrorStore>;
68
+ };
69
+ type ExportableDiffSet = {
70
+ newTypes: Array<TypeStore>;
71
+ deprecatedTypes: Array<TypeStore>;
72
+ objectTypeChanges: Array<ObjectTypeChangeStore>;
73
+ incompatibleChanges: Array<ErrorStore>;
74
+ };
75
+ export type Framework = "ReactNative";
76
+ export type SchemaDiffers = {
77
+ incompatibleSpecs: null | undefined | Set<NativeSpecErrorStore>;
78
+ };
79
+ type ExportableSchemaDiffers = {
80
+ incompatibleSpecs: null | undefined | Array<ExportableNativeSpecErrorStore>;
81
+ };
82
+ export type SchemaDiffCategory = "new" | "deprecated" | SchemaDiffers;
83
+ type ExportableSchemaDiffCategory =
84
+ | "new"
85
+ | "deprecated"
86
+ | ExportableSchemaDiffers;
87
+ export type SchemaDiff = {
88
+ name: string;
89
+ framework: Framework;
90
+ status: SchemaDiffCategory;
91
+ };
92
+ export type ExportableSchemaDiff = {
93
+ name: string;
94
+ framework: Framework;
95
+ status: ExportableSchemaDiffCategory;
96
+ };
97
+ export type Version = { device: "android" | "ios"; number: string };
98
+ export type Incompatible = {
99
+ framework: Framework;
100
+ incompatibleSpecs?: Array<NativeSpecErrorStore>;
101
+ };
102
+ export type IncompatiblityReport = { [hasteModuleName: string]: Incompatible };
103
+ export type DiffSummary = {
104
+ /** status records how the diff compares against older versions
105
+ * ok: there are no changes that impact older versions
106
+ * patchable: there are additions (or modifications) that are not suported
107
+ * in older versions but is safe with an auto-generated patch
108
+ * incompatible: there are modifications that are not safe for use with older
109
+ * versions and are not fixable with an auto-generated patchable
110
+ */
111
+ status: "ok" | "patchable" | "incompatible";
112
+ incompatibilityReport: IncompatiblityReport;
113
+ };
114
+ export type FormattedIncompatible = {
115
+ framework: Framework;
116
+ incompatibleSpecs?: Array<FormattedErrorStore>;
117
+ };
118
+ export type FormattedIncompatiblityReport = {
119
+ [hasteModuleName: string]: FormattedIncompatible;
120
+ };
121
+ export type FormattedDiffSummary = {
122
+ /** status records how the diff compares against older versions
123
+ * ok: there are no changes that impact older versions
124
+ * patchable: there are additions (or modifications) that are not suported
125
+ * in older versions but is safe with an auto-generated patch
126
+ * incompatible: there are modifications that are not safe for use with older
127
+ * versions and are not fixable with an auto-generated patchable
128
+ */
129
+ status: "ok" | "patchable" | "incompatible";
130
+ incompatibilityReport: FormattedIncompatiblityReport;
131
+ };
132
+ export declare function nativeSpecErrorExporter(
133
+ nativeSpecError: NativeSpecErrorStore
134
+ ): ExportableNativeSpecErrorStore;
135
+ export declare function schemaDiffExporter(
136
+ schemaDiff: SchemaDiff
137
+ ): ExportableSchemaDiff;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true,
5
+ });
6
+ exports.nativeSpecErrorExporter = nativeSpecErrorExporter;
7
+ exports.schemaDiffExporter = schemaDiffExporter;
8
+ function diffSetExporter(diffSet) {
9
+ return {
10
+ newTypes: Array.from(diffSet.newTypes),
11
+ deprecatedTypes: Array.from(diffSet.deprecatedTypes),
12
+ objectTypeChanges: Array.from(diffSet.objectTypeChanges),
13
+ incompatibleChanges: Array.from(diffSet.incompatibleChanges),
14
+ };
15
+ }
16
+ function nativeSpecErrorExporter(nativeSpecError) {
17
+ if (nativeSpecError.changeInformation) {
18
+ return {
19
+ nativeSpecName: nativeSpecError.nativeSpecName,
20
+ omitted: nativeSpecError.omitted,
21
+ errorCode: nativeSpecError.errorCode,
22
+ errorInformation: nativeSpecError.errorInformation,
23
+ changeInformation: diffSetExporter(nativeSpecError.changeInformation),
24
+ };
25
+ }
26
+ return {
27
+ nativeSpecName: nativeSpecError.nativeSpecName,
28
+ omitted: nativeSpecError.omitted,
29
+ errorCode: nativeSpecError.errorCode,
30
+ errorInformation: nativeSpecError.errorInformation,
31
+ };
32
+ }
33
+ function schemaDiffCategoryExporter(status) {
34
+ switch (status) {
35
+ case "new":
36
+ case "deprecated":
37
+ return status;
38
+ default:
39
+ return {
40
+ incompatibleSpecs: status.incompatibleSpecs
41
+ ? Array.from(status.incompatibleSpecs).map(nativeSpecErrorExporter)
42
+ : undefined,
43
+ };
44
+ }
45
+ }
46
+ function schemaDiffExporter(schemaDiff) {
47
+ return {
48
+ name: schemaDiff.name,
49
+ framework: schemaDiff.framework,
50
+ status: schemaDiffCategoryExporter(schemaDiff.status),
51
+ };
52
+ }
@@ -0,0 +1,160 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict-local
8
+ * @format
9
+ */
10
+
11
+ import type {
12
+ PropertiesComparisonResult,
13
+ TypeComparisonError,
14
+ } from "./ComparisonResult";
15
+ import type { CompleteTypeAnnotation } from "@react-native/codegen/src/CodegenSchema";
16
+
17
+ export type ErrorCode =
18
+ | "addedProps"
19
+ | "removedProps"
20
+ | "changedParams"
21
+ | "incompatibleTypes"
22
+ | "requiredProps"
23
+ | "optionalProps"
24
+ | "nonNullableOfNull"
25
+ | "nullableOfNonNull"
26
+ | "removedUnionCases"
27
+ | "addedUnionCases"
28
+ | "addedEnumCases"
29
+ | "removedEnumCases"
30
+ | "removedIntersectCases"
31
+ | "addedIntersectCases"
32
+ | "removedModule"
33
+ | "removedComponent";
34
+
35
+ export type TypeStore = {
36
+ typeName: string,
37
+ typeInformation: CompleteTypeAnnotation,
38
+ ...
39
+ };
40
+ // Stores object properties that are added or removed which could be patchable
41
+ export type ObjectTypeChangeStore = {
42
+ typeName: string,
43
+ newType: CompleteTypeAnnotation,
44
+ oldType: CompleteTypeAnnotation,
45
+ propertyChange: PropertiesComparisonResult,
46
+ };
47
+ export type ErrorStore = {
48
+ typeName: string,
49
+ errorCode: ErrorCode,
50
+ errorInformation: TypeComparisonError,
51
+ };
52
+ export type FormattedErrorStore = {
53
+ message: string,
54
+ errorCode: ErrorCode,
55
+ };
56
+ export type NativeSpecErrorStore = {
57
+ nativeSpecName: string,
58
+ omitted: boolean,
59
+ errorCode: ErrorCode,
60
+ errorInformation?: TypeComparisonError,
61
+ changeInformation?: DiffSet,
62
+ };
63
+ export type ExportableNativeSpecErrorStore = {
64
+ nativeSpecName: string,
65
+ omitted: boolean,
66
+ errorCode: ErrorCode,
67
+ errorInformation?: TypeComparisonError,
68
+ changeInformation?: ExportableDiffSet,
69
+ };
70
+ export type DiffSet = {
71
+ newTypes: Set<TypeStore>,
72
+ deprecatedTypes: Set<TypeStore>,
73
+ objectTypeChanges: Set<ObjectTypeChangeStore>,
74
+ incompatibleChanges: Set<ErrorStore>,
75
+ };
76
+ type ExportableDiffSet = {
77
+ newTypes: Array<TypeStore>,
78
+ deprecatedTypes: Array<TypeStore>,
79
+ objectTypeChanges: Array<ObjectTypeChangeStore>,
80
+ incompatibleChanges: Array<ErrorStore>,
81
+ };
82
+
83
+ export type Framework = "ReactNative";
84
+ export type SchemaDiffers = {
85
+ incompatibleSpecs: ?Set<NativeSpecErrorStore>,
86
+ };
87
+ type ExportableSchemaDiffers = {
88
+ incompatibleSpecs: ?Array<ExportableNativeSpecErrorStore>,
89
+ };
90
+ export type SchemaDiffCategory = "new" | "deprecated" | SchemaDiffers;
91
+ type ExportableSchemaDiffCategory =
92
+ | "new"
93
+ | "deprecated"
94
+ | ExportableSchemaDiffers;
95
+ export type SchemaDiff = {
96
+ name: string,
97
+ framework: Framework,
98
+ status: SchemaDiffCategory,
99
+ };
100
+ export type ExportableSchemaDiff = {
101
+ name: string,
102
+ framework: Framework,
103
+ status: ExportableSchemaDiffCategory,
104
+ };
105
+
106
+ export type Version = {
107
+ device: "android" | "ios",
108
+ number: string,
109
+ ...
110
+ };
111
+
112
+ export type Incompatible = {
113
+ framework: Framework,
114
+ incompatibleSpecs?: Array<NativeSpecErrorStore>,
115
+ };
116
+ export type IncompatiblityReport = {
117
+ [hasteModuleName: string]: Incompatible,
118
+ };
119
+ export type DiffSummary = {
120
+ /** status records how the diff compares against older versions
121
+ * ok: there are no changes that impact older versions
122
+ * patchable: there are additions (or modifications) that are not suported
123
+ * in older versions but is safe with an auto-generated patch
124
+ * incompatible: there are modifications that are not safe for use with older
125
+ * versions and are not fixable with an auto-generated patchable
126
+ */
127
+ status: "ok" | "patchable" | "incompatible",
128
+ // If there are incompatible changes, provide a record of them, otherwise {}
129
+ incompatibilityReport: IncompatiblityReport,
130
+ };
131
+
132
+ export type FormattedIncompatible = {
133
+ framework: Framework,
134
+ incompatibleSpecs?: Array<FormattedErrorStore>,
135
+ };
136
+
137
+ export type FormattedIncompatiblityReport = {
138
+ [hasteModuleName: string]: FormattedIncompatible,
139
+ };
140
+
141
+ export type FormattedDiffSummary = {
142
+ /** status records how the diff compares against older versions
143
+ * ok: there are no changes that impact older versions
144
+ * patchable: there are additions (or modifications) that are not suported
145
+ * in older versions but is safe with an auto-generated patch
146
+ * incompatible: there are modifications that are not safe for use with older
147
+ * versions and are not fixable with an auto-generated patchable
148
+ */
149
+ status: "ok" | "patchable" | "incompatible",
150
+ // If there are incompatible changes, provide a record of them, otherwise {}
151
+ incompatibilityReport: FormattedIncompatiblityReport,
152
+ };
153
+
154
+ declare export function nativeSpecErrorExporter(
155
+ nativeSpecError: NativeSpecErrorStore
156
+ ): ExportableNativeSpecErrorStore;
157
+
158
+ declare export function schemaDiffExporter(
159
+ schemaDiff: SchemaDiff
160
+ ): ExportableSchemaDiff;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ * @format
9
+ */
10
+
11
+ import type { TypeComparisonError } from "./ComparisonResult";
12
+ import type {
13
+ DiffSummary,
14
+ ErrorStore,
15
+ FormattedDiffSummary,
16
+ FormattedErrorStore,
17
+ NativeSpecErrorStore,
18
+ } from "./DiffResults";
19
+ export declare function formatErrorMessage(
20
+ error: TypeComparisonError,
21
+ indent: number
22
+ ): string;
23
+ export declare function formatErrorStore(
24
+ errorStore: ErrorStore
25
+ ): FormattedErrorStore;
26
+ export declare function formatNativeSpecErrorStore(
27
+ specError: NativeSpecErrorStore
28
+ ): Array<FormattedErrorStore>;
29
+ export declare function formatDiffSet(
30
+ summary: DiffSummary
31
+ ): FormattedDiffSummary;
@@ -0,0 +1,272 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true,
5
+ });
6
+ exports.formatDiffSet = formatDiffSet;
7
+ exports.formatErrorMessage = formatErrorMessage;
8
+ exports.formatErrorStore = formatErrorStore;
9
+ exports.formatNativeSpecErrorStore = formatNativeSpecErrorStore;
10
+ function indentedLineStart(indent) {
11
+ return "\n" + " ".repeat(indent);
12
+ }
13
+ function formatErrorMessage(error, indent = 0) {
14
+ switch (error.type) {
15
+ case "PropertyComparisonError":
16
+ const formattedProperties = error.mismatchedProperties.map(
17
+ (individualPropertyError) =>
18
+ indentedLineStart(indent + 1) +
19
+ "-- " +
20
+ individualPropertyError.property +
21
+ (individualPropertyError.fault
22
+ ? ": " +
23
+ formatErrorMessage(individualPropertyError.fault, indent + 2)
24
+ : "")
25
+ );
26
+ return error.message + formattedProperties.join("");
27
+ case "PositionalComparisonError":
28
+ const formattedPositionalChanges = error.erroneousItems.map(
29
+ ([index, type]) =>
30
+ indentedLineStart(indent + 1) +
31
+ "-- position " +
32
+ index +
33
+ " " +
34
+ formatTypeAnnotation(type)
35
+ );
36
+ return error.message + formattedPositionalChanges.join("");
37
+ case "TypeAnnotationComparisonError":
38
+ const previousError = error.previousError;
39
+ return (
40
+ error.message +
41
+ indentedLineStart(indent + 1) +
42
+ "--new: " +
43
+ formatTypeAnnotation(error.newerAnnotation) +
44
+ indentedLineStart(indent + 1) +
45
+ "--old: " +
46
+ formatTypeAnnotation(error.olderAnnotation) +
47
+ (previousError != null
48
+ ? indentedLineStart(indent + 1) +
49
+ "" +
50
+ formatErrorMessage(previousError, indent + 2)
51
+ : "")
52
+ );
53
+ case "TypeInformationComparisonError":
54
+ return (
55
+ error.message +
56
+ indentedLineStart(indent + 1) +
57
+ "-- new: " +
58
+ formatTypeAnnotation(error.newerType) +
59
+ indentedLineStart(indent + 1) +
60
+ "-- old: " +
61
+ formatTypeAnnotation(error.olderType)
62
+ );
63
+ case "MemberComparisonError":
64
+ const formattedMembers = error.mismatchedMembers.map(
65
+ (individualMemberError) =>
66
+ indentedLineStart(indent + 1) +
67
+ "-- Member " +
68
+ individualMemberError.member +
69
+ (individualMemberError.fault
70
+ ? ": " + formatErrorMessage(individualMemberError.fault, indent + 2)
71
+ : "")
72
+ );
73
+ return error.message + formattedMembers.join("");
74
+ default:
75
+ error.type;
76
+ return "";
77
+ }
78
+ }
79
+ function formatTypeAnnotation(annotation) {
80
+ switch (annotation.type) {
81
+ case "AnyTypeAnnotation":
82
+ return "any";
83
+ case "ArrayTypeAnnotation":
84
+ return "Array<" + formatTypeAnnotation(annotation.elementType) + ">";
85
+ case "BooleanTypeAnnotation":
86
+ return "boolean";
87
+ case "EnumDeclaration": {
88
+ let shortHandType = "";
89
+ switch (annotation.memberType) {
90
+ case "StringTypeAnnotation":
91
+ shortHandType = "string";
92
+ break;
93
+ case "NumberTypeAnnotation":
94
+ shortHandType = "number";
95
+ break;
96
+ default:
97
+ annotation.memberType;
98
+ throw new Error("Unexpected enum memberType");
99
+ }
100
+ return `Enum<${shortHandType}>` + "";
101
+ }
102
+ case "EnumDeclarationWithMembers": {
103
+ let shortHandType = "";
104
+ switch (annotation.memberType) {
105
+ case "StringTypeAnnotation":
106
+ shortHandType = "string";
107
+ break;
108
+ case "NumberTypeAnnotation":
109
+ shortHandType = "number";
110
+ break;
111
+ default:
112
+ annotation.memberType;
113
+ throw new Error("Unexptected enum memberType");
114
+ }
115
+ return (
116
+ `Enum<${shortHandType}> {` +
117
+ annotation.members
118
+ .map(
119
+ (member) => `${member.name} = ${formatTypeAnnotation(member.value)}`
120
+ )
121
+ .join(", ") +
122
+ "}"
123
+ );
124
+ }
125
+ case "FunctionTypeAnnotation":
126
+ return (
127
+ "(" +
128
+ annotation.params
129
+ .map(
130
+ (param) =>
131
+ param.name +
132
+ (param.optional ? "?" : "") +
133
+ ": " +
134
+ formatTypeAnnotation(param.typeAnnotation)
135
+ )
136
+ .join(", ") +
137
+ ")" +
138
+ "=>" +
139
+ formatTypeAnnotation(annotation.returnTypeAnnotation)
140
+ );
141
+ case "NullableTypeAnnotation":
142
+ return "?" + formatTypeAnnotation(annotation.typeAnnotation);
143
+ case "NumberTypeAnnotation":
144
+ return "number";
145
+ case "DoubleTypeAnnotation":
146
+ return "double";
147
+ case "FloatTypeAnnotation":
148
+ return "float";
149
+ case "Int32TypeAnnotation":
150
+ return "int";
151
+ case "NumberLiteralTypeAnnotation":
152
+ return annotation.value.toString();
153
+ case "ObjectTypeAnnotation":
154
+ return (
155
+ "{" +
156
+ annotation.properties
157
+ .map(
158
+ (property) =>
159
+ property.name +
160
+ (property.optional ? "?" : "") +
161
+ ": " +
162
+ formatTypeAnnotation(property.typeAnnotation)
163
+ )
164
+ .join(", ") +
165
+ "}"
166
+ );
167
+ case "StringLiteralTypeAnnotation":
168
+ return parseInt(annotation.value, 10).toString() === annotation.value ||
169
+ annotation.value.includes(" ")
170
+ ? `'${annotation.value}'`
171
+ : annotation.value;
172
+ case "StringLiteralUnionTypeAnnotation":
173
+ return (
174
+ "(" +
175
+ annotation.types
176
+ .map((stringLit) => formatTypeAnnotation(stringLit))
177
+ .join(" | ") +
178
+ ")"
179
+ );
180
+ case "StringTypeAnnotation":
181
+ return "string";
182
+ case "UnionTypeAnnotation": {
183
+ const shortHandType =
184
+ annotation.memberType === "StringTypeAnnotation"
185
+ ? "string"
186
+ : annotation.memberType === "ObjectTypeAnnotation"
187
+ ? "Object"
188
+ : "number";
189
+ return `Union<${shortHandType}>`;
190
+ }
191
+ case "PromiseTypeAnnotation":
192
+ return "Promise<" + formatTypeAnnotation(annotation.elementType) + ">";
193
+ case "EventEmitterTypeAnnotation":
194
+ return (
195
+ "EventEmitter<" + formatTypeAnnotation(annotation.typeAnnotation) + ">"
196
+ );
197
+ case "TypeAliasTypeAnnotation":
198
+ case "ReservedTypeAnnotation":
199
+ return annotation.name;
200
+ case "VoidTypeAnnotation":
201
+ return "void";
202
+ case "MixedTypeAnnotation":
203
+ return "mixed";
204
+ case "GenericObjectTypeAnnotation":
205
+ if (annotation.dictionaryValueType) {
206
+ return `{[string]: ${formatTypeAnnotation(
207
+ annotation.dictionaryValueType
208
+ )}`;
209
+ }
210
+ return "Object";
211
+ default:
212
+ annotation.type;
213
+ return JSON.stringify(annotation);
214
+ }
215
+ }
216
+ function formatErrorStore(errorStore) {
217
+ return {
218
+ message:
219
+ errorStore.typeName +
220
+ ": " +
221
+ formatErrorMessage(errorStore.errorInformation),
222
+ errorCode: errorStore.errorCode,
223
+ };
224
+ }
225
+ function formatNativeSpecErrorStore(specError) {
226
+ if (specError.errorInformation) {
227
+ return [
228
+ {
229
+ message:
230
+ specError.nativeSpecName +
231
+ ": " +
232
+ formatErrorMessage(specError.errorInformation),
233
+ errorCode: specError.errorCode,
234
+ },
235
+ ];
236
+ }
237
+ if (specError.changeInformation?.incompatibleChanges != null) {
238
+ return Array.from(specError.changeInformation.incompatibleChanges).map(
239
+ (errorStore) => formatErrorStore(errorStore)
240
+ );
241
+ }
242
+ return [];
243
+ }
244
+ function formatDiffSet(summary) {
245
+ const summaryStatus = summary.status;
246
+ if (summaryStatus === "ok" || summaryStatus === "patchable") {
247
+ return summary;
248
+ }
249
+ const hasteModules = Object.keys(summary.incompatibilityReport);
250
+ const incompatibles = summary.incompatibilityReport;
251
+ const formattedIncompatibilities = {};
252
+ hasteModules.forEach((hasteModule) => {
253
+ const incompat = incompatibles[hasteModule];
254
+ const formattedIncompat = {
255
+ framework: incompat.framework,
256
+ };
257
+ if (incompat.incompatibleSpecs) {
258
+ formattedIncompat.incompatibleSpecs = incompat.incompatibleSpecs.reduce(
259
+ (formattedModuleErrors, specErrorStore) =>
260
+ formattedModuleErrors.concat(
261
+ formatNativeSpecErrorStore(specErrorStore)
262
+ ),
263
+ []
264
+ );
265
+ }
266
+ formattedIncompatibilities[hasteModule] = formattedIncompat;
267
+ });
268
+ return {
269
+ status: summaryStatus,
270
+ incompatibilityReport: formattedIncompatibilities,
271
+ };
272
+ }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict-local
8
+ * @format
9
+ */
10
+
11
+ import type { TypeComparisonError } from "./ComparisonResult";
12
+ import type {
13
+ DiffSummary,
14
+ ErrorStore,
15
+ FormattedDiffSummary,
16
+ FormattedErrorStore,
17
+ NativeSpecErrorStore,
18
+ } from "./DiffResults";
19
+ declare export function formatErrorMessage(
20
+ error: TypeComparisonError,
21
+ indent: number
22
+ ): string;
23
+
24
+ declare export function formatErrorStore(
25
+ errorStore: ErrorStore
26
+ ): FormattedErrorStore;
27
+
28
+ declare export function formatNativeSpecErrorStore(
29
+ specError: NativeSpecErrorStore
30
+ ): Array<FormattedErrorStore>;
31
+
32
+ declare export function formatDiffSet(
33
+ summary: DiffSummary
34
+ ): FormattedDiffSummary;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ * @format
9
+ */
10
+
11
+ import type { CompleteTypeAnnotation } from "@react-native/codegen/src/CodegenSchema";
12
+ export declare function sortTypeAnnotations(
13
+ annotations: ReadonlyArray<CompleteTypeAnnotation>
14
+ ): Array<[number, CompleteTypeAnnotation]>;
15
+ export declare function compareTypeAnnotationForSorting(
16
+ $$PARAM_0$$: [number, CompleteTypeAnnotation],
17
+ $$PARAM_1$$: [number, CompleteTypeAnnotation]
18
+ ): number;