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
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