Skip to content

Commit 52c54fd

Browse files
committed
Core Data: Check for presence of entity config before testing plural form.
When auto-generating method names for various entities in the data system we want to use manually-listed plural forms if they exist. Previously, however, we've been assuming that when we search for an entity's config that it exists. While this probably hasn't been a real source of bugs it does present an opportunity for an invalid-type runtime exception. In this patch we're verifying that the config exists before we access the `plural` property, eliminating the opportunity for the rutnime crash.
1 parent 05b8a7d commit 52c54fd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/core-data/src/entities.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ export const getMethodName = (
297297
const nameSuffix =
298298
upperFirst( camelCase( name ) ) + ( usePlural ? 's' : '' );
299299
const suffix =
300-
usePlural && entityConfig.plural
300+
usePlural && entityConfig?.plural
301301
? upperFirst( camelCase( entityConfig.plural ) )
302302
: nameSuffix;
303303
return `${ prefix }${ kindPrefix }${ suffix }`;

0 commit comments

Comments
 (0)