WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.35k stars 4.13k forks source link

Cannot read properties of undefined (reading 'store') #63006

Open mxvsh opened 2 months ago

mxvsh commented 2 months ago

Description

Package @wordpress/core-data isn't working. It returns undefined when I try to import it in a TypeScript project.

Here's ny TSConfig

{
    "compilerOptions": {
        "jsx": "react-jsx",
        "module": "ESNext",
        "target": "ES2016",
        "strict": true,
        "allowSyntheticDefaultImports": true,
        "moduleResolution": "node"
    }
}

Step-by-step reproduction instructions

  1. Install @wordpress/core-data
  2. Add following code
    import { store } from '@wordpress/core-data';
    console.log('store', store);
  3. You should get an error.

Screenshots, screen recording, code snippet

Code:

Screenshot 2024-07-01 at 14 00 23

Result:

Screenshot 2024-07-01 at 13 58 04

Environment info

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

github-actions[bot] commented 1 month ago

Hi, This issue has gone 30 days without any activity. This means it is time for a check-in to make sure it is still relevant. If you are still experiencing this issue with the latest versions, you can help the project by responding to confirm the problem and by providing any updated reproduction steps. Thanks for helping out.

miminari commented 1 month ago

Thank you for reporting. I tested this on WordPress 6.6.1, and I wasn't be able to reproduced, doing like below steps:

  1. npx @wordpress/create-block@latest error-test
  2. cd error-test
  3. npx @wp-now/wp-now start --reset
  4. Change the files to Typescript(index.ts, edit.tsx, save.tsx) , Add tsconfig.json and npm i -D @types/wordpress__blocks @types/wordpress__block-editor
  5. Add the code on edit.tsx
  6. npm run start

SS_2024-08-14 10 55 22

It seems to work nice probably.

github-actions[bot] commented 6 days ago

Hi, This issue has gone 30 days without any activity. This means it is time for a check-in to make sure it is still relevant. If you are still experiencing this issue with the latest versions, you can help the project by responding to confirm the problem and by providing any updated reproduction steps. Thanks for helping out.