141
): string {
142
switch (result) {
143
case CompareDependencyResult.Ok:
144
- return 'dependencies equal';
144
+ return 'Dependencies equal';
145
case CompareDependencyResult.RootDifference:
146
case CompareDependencyResult.PathDifference:
147
- return 'inferred different dependency than source';
147
+ return 'Inferred different dependency than source';
148
case CompareDependencyResult.RefAccessDifference:
149
- return 'differences in ref.current access';
149
+ return 'Differences in ref.current access';
150
case CompareDependencyResult.Subpath:
151
- return 'inferred less specific property than source';
151
+ return 'Inferred less specific property than source';
152
}
153
}
154
279
severity: ErrorSeverity.CannotPreserveMemoization,
280
reason:
281
'React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. The inferred dependencies did not match the manually specified dependencies, which could cause the value to change more or less frequently than expected',
282
- description: DEBUG
283
- ? `The inferred dependency was \`${prettyPrintScopeDependency(
284
- dep,
285
- )}\`, but the source dependencies were [${validDepsInMemoBlock
286
- .map(dep => printManualMemoDependency(dep, true))
287
- .join(', ')}]. Detail: ${
288
- errorDiagnostic
289
- ? getCompareDependencyResultDescription(errorDiagnostic)
290
- : 'none'
291
- }`
292
- : null,
282
+ description:
283
+ DEBUG ||
284
+ // If the dependency is a named variable then we can report it. Otherwise only print in debug mode
285
+ (dep.identifier.name != null && dep.identifier.name.kind === 'named')
286
+ ? `The inferred dependency was \`${prettyPrintScopeDependency(
287
+ dep,
288
+ )}\`, but the source dependencies were [${validDepsInMemoBlock
289
+ .map(dep => printManualMemoDependency(dep, true))
290
+ .join(', ')}]. ${
291
+ errorDiagnostic
292
+ ? getCompareDependencyResultDescription(errorDiagnostic)
293
+ : 'Inferred dependency not present in source'
294
+ }`
295
+ : null,
296
loc: memoLocation,
297
suggestions: null,
298
});