Skip to content

Commit

Permalink
Core Data: Pass explicit undefined initial value to createContext
Browse files Browse the repository at this point in the history
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
1 parent b115040 commit 945b756
Showing 1 changed file with 6 additions and 2 deletions.
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

0 comments on commit 945b756

Please sign in to comment.