Skip to content

Docs: Interactivity API - TypeScript snippet is used in the sample. #64418

Closed

Description

Description

Actions section of 'Elements of the store' is using TypeScript snippet.
https://github.com/WordPress/gutenberg/blob/trunk/docs/reference-guides/interactivity-api/api-reference.md
Can we use TypeScript snippet without any notice? How do we implement it in view.js?

const { state, actions } = store("myPlugin", {
  actions: {
    selectItem: (id?: number) => {
      const context = getContext();
      // `id` is optional here, so this action can be used in a directive.
      state.selected = id || context.id;
    },
    otherAction: () => {
      // but it can also be called from other actions.
      actions.selectItem(123); // it works and type is correct
    }
  }
});

Step-by-step reproduction instructions

Refer https://github.com/WordPress/gutenberg/blob/trunk/docs/reference-guides/interactivity-api/api-reference.md

Screenshots, screen recording, code snippet

No response

Environment info

No response

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    [Type] BugAn existing feature does not function as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions