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
…WordPress#39526)

Part of WordPress#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 authored and jostnes committed Mar 23, 2022
1 parent a8345d0 commit bd8553e
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 @@ -29,7 +29,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 @@ -43,7 +45,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 bd8553e

Please sign in to comment.