Skip to content

TypeScript type is missing selectors in @wordpress/core-data store #67847

@anomiex

Description

@anomiex

When attempting to compile TypeScript code like this:

import { store as coreStore } from '@wordpress/core-data';
import { createRegistrySelector } from '@wordpress/data';

createRegistrySelector( select => () => {
    const { getSite } = select( coreStore );
} );

using @wordpress/core-data 7.14.0 and @wordpress/data 10.14.0, tsc gives an error

index.ts:5:13 - error TS2339: Property 'getSite' does not exist on type '{ getAuthors: (query?: { [x: string]: any; }) => User<"edit">[]; getCurrentUser: () => User<"edit">; getEntitiesByKind: (kind: string) => any[]; getEntity: (kind: string, name: string) => any; ... 45 more ...; getRevision: any; }'.

5     const { getSite } = select( coreStore );
              ~~~~~~~


Found 1 error in index.ts:5

Digging into it a bit, with reference to this code

const storeConfig = () => ( {
reducer,
actions: { ...actions, ...entityActions, ...createLocksActions() },
selectors: { ...selectors, ...entitySelectors },
resolvers: { ...resolvers, ...entityResolvers },
} );

it seems the typing for the store in node_modules/@wordpress/core-data/build-types/index.d.ts reflects only the selectors from selectors, all those from entitySelectors are missing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions