Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Core Data: Pass explicit undefined initial value to createContext
Part of #39211

Previously we have been calling `createContext()` without any
arguments, but there's a funny note in the official React type
for that function.

> // If you thought this should be optional, see
> // DefinitelyTyped/DefinitelyTyped#24509 (comment)

Although not passing an argument is practically the same as passing
`undefined` as the argument we have a type error that TypeScript
doesn't like while we're relying on it to parse JS files with the
JSDoc typings.

In this patch we're just adding the explicit `undefined` which should
have no behavioral change on the output but removes the type issue.
  • Loading branch information
dmsnell committed Mar 17, 2022
commit 945b7563d1510a056b3f416c081ceecb5e88cec9
8 changes: 6 additions & 2 deletions packages/core-data/src/entity-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ const entityContexts = {
if ( ! acc[ loader.kind ] ) {
acc[ loader.kind ] = {};
}
acc[ loader.kind ][ loader.name ] = { context: createContext() };
acc[ loader.kind ][ loader.name ] = {
context: createContext( undefined ),
};
return acc;
}, {} ),
...additionalEntityConfigLoaders.reduce( ( acc, loader ) => {
Expand All @@ -41,7 +43,9 @@ const getEntityContext = ( kind, name ) => {
}

if ( ! entityContexts[ kind ][ name ] ) {
entityContexts[ kind ][ name ] = { context: createContext() };
entityContexts[ kind ][ name ] = {
context: createContext( undefined ),
};
}

return entityContexts[ kind ][ name ].context;
Expand Down