Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blocks: Try adding TypeScript type checking and improved JSDoc #16552

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ _Parameters_

_Returns_

- `Array<Object>`: Whether block type matches search term.
- `boolean`: Whether block type matches search term.


<!-- END TOKEN(Autogenerated selectors) -->
Expand Down
223 changes: 221 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,21 @@
"@babel/runtime-corejs3": "7.4.4",
"@babel/traverse": "7.4.4",
"@octokit/rest": "16.26.0",
"@types/jest": "24.0.15",
"@types/lodash": "4.14.136",
"@types/wordpress__autop": "2.3.0",
"@types/wordpress__blob": "2.4.0",
"@types/wordpress__block-serialization-default-parser": "3.2.0",
"@types/wordpress__block-serialization-spec-parser": "3.1.0",
"@types/wordpress__blocks": "6.4.3",
"@types/wordpress__compose": "3.4.0",
"@types/wordpress__dom": "2.3.0",
"@types/wordpress__element": "2.4.0",
"@types/wordpress__hooks": "2.4.0",
"@types/wordpress__html-entities": "2.3.0",
"@types/wordpress__i18n": "3.4.0",
"@types/wordpress__jest-console": "3.0.0",
"@types/wordpress__shortcode": "2.3.0",
"@wordpress/babel-plugin-import-jsx-pragma": "file:packages/babel-plugin-import-jsx-pragma",
"@wordpress/babel-plugin-makepot": "file:packages/babel-plugin-makepot",
"@wordpress/babel-preset-default": "file:packages/babel-preset-default",
Expand Down Expand Up @@ -136,6 +151,7 @@
"source-map-loader": "0.2.4",
"sprintf-js": "1.1.1",
"stylelint-config-wordpress": "13.1.0",
"typescript": "3.5.3",
"uuid": "3.3.2",
"webpack": "4.8.3",
"worker-farm": "1.7.0"
Expand Down
6 changes: 3 additions & 3 deletions packages/blocks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ Returns an array with the child blocks of a given block.

_Parameters_

- _blockName_ `string`: Name of block (example: “latest-posts”).
- _blockName_ `string`: Name of block (example: 'core/columns').

_Returns_

Expand Down Expand Up @@ -464,7 +464,7 @@ Returns a boolean indicating if a block has child blocks or not.

_Parameters_

- _blockName_ `string`: Name of block (example: latest-posts).
- _blockName_ `string`: Name of block (example: 'core/latest-posts').

_Returns_

Expand Down Expand Up @@ -614,7 +614,7 @@ Registers a new block style variation for the given block.

_Parameters_

- _blockName_ `string`: Name of block (example: core/latest-posts”).
- _blockName_ `string`: Name of block (example: 'core/paragraph').
- _styleVariation_ `Object`: Object containing `name` which is the class name applied to the block and `label` which identifies the variation to the user.

<a name="registerBlockType" href="#registerBlockType">#</a> **registerBlockType**
Expand Down
12 changes: 8 additions & 4 deletions packages/blocks/src/api/categories.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
*/
import { dispatch, select } from '@wordpress/data';

/**
* @typedef {import('@wordpress/blocks').Category} Category
*/

/**
* Returns all the block categories.
*
* @return {Object[]} Block categories.
* @return {Category[]} Block categories.
*/
export function getCategories() {
return select( 'core/blocks' ).getCategories();
Expand All @@ -15,7 +19,7 @@ export function getCategories() {
/**
* Sets the block categories.
*
* @param {Object[]} categories Block categories.
* @param {Category[]} categories Block categories.
*/
export function setCategories( categories ) {
dispatch( 'core/blocks' ).setCategories( categories );
Expand All @@ -24,8 +28,8 @@ export function setCategories( categories ) {
/**
* Updates a category.
*
* @param {string} slug Block category slug.
* @param {Object} category Object containing the category properties that should be updated.
* @param {string} slug Block category slug.
* @param {Partial<Category>} category Object containing the category properties that should be updated.
*/
export function updateCategory( slug, category ) {
dispatch( 'core/blocks' ).updateCategory( slug, category );
Expand Down
Loading