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

feature: add TypeScript types to the blocks package #48604

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
82 changes: 41 additions & 41 deletions docs/reference-guides/data/data-core-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ const ExampleComponent = () => {

_Parameters_

- _state_ `Object`: Data state.
- _state_ `BlockStoreState`: Data state.
- _blockName_ `string`: Name of block (example: “core/columns”).
- _attributes_ `Object`: Block attributes used to determine active variation.
- _scope_ `[WPBlockVariationScope]`: Block variation scope name.
- _attributes_ `BlockAttributes`: Block attributes used to determine active variation.
- _scope_ `BlockVariationScope=`: Block variation scope name.

_Returns_

- `(WPBlockVariation|undefined)`: Active block variation.
- `BlockVariation|undefined`: Active block variation.

### getBlockStyles

Expand Down Expand Up @@ -83,12 +83,12 @@ const ExampleComponent = () => {

_Parameters_

- _state_ `Object`: Data state.
- _state_ `BlockStoreState`: Data state.
- _name_ `string`: Block type name.

_Returns_

- `Array?`: Block Styles.
- `BlockStyle[]|undefined`: Block Styles.

### getBlockSupport

Expand Down Expand Up @@ -121,14 +121,14 @@ const ExampleComponent = () => {

_Parameters_

- _state_ `Object`: Data state.
- _nameOrType_ `(string|Object)`: Block name or type object
- _feature_ `Array|string`: Feature to retrieve
- _state_ `BlockStoreState`: Data state.
- _nameOrType_ `string|BlockType`: Block name or type object
- _feature_ `string|string[]`: Feature to retrieve
- _defaultSupports_ `*`: Default value to return if not explicitly defined

_Returns_

- `?*`: Block support value
- `*`: Block support value

### getBlockType

Expand Down Expand Up @@ -167,12 +167,12 @@ const ExampleComponent = () => {

_Parameters_

- _state_ `Object`: Data state.
- _state_ `BlockStoreState`: Data state.
- _name_ `string`: Block type name.

_Returns_

- `Object?`: Block Type.
- `BlockType|undefined`: Block Type.

### getBlockTypes

Expand Down Expand Up @@ -202,11 +202,11 @@ const ExampleComponent = () => {

_Parameters_

- _state_ `Object`: Data state.
- _state_ `BlockStoreState`: Data state.

_Returns_

- `Array`: Block Types.
- `BlockType[]`: Block Types.

### getBlockVariations

Expand Down Expand Up @@ -238,13 +238,13 @@ const ExampleComponent = () => {

_Parameters_

- _state_ `Object`: Data state.
- _state_ `BlockStoreState`: Data state.
- _blockName_ `string`: Block type name.
- _scope_ `[WPBlockVariationScope]`: Block variation scope name.
- _scope_ `BlockVariationScope=`: Block variation scope name.

_Returns_

- `(WPBlockVariation[]|void)`: Block variations.
- `(BlockVariation[]|undefined) & EnhancedSelector`: Block variations.

### getCategories

Expand Down Expand Up @@ -274,11 +274,11 @@ const ExampleComponent = () => {

_Parameters_

- _state_ `Object`: Data state.
- _state_ `BlockStoreState`: Data state.

_Returns_

- `WPBlockCategory[]`: Categories list.
- `BlockCategory[]`: Categories list.

### getChildBlockNames

Expand Down Expand Up @@ -310,12 +310,12 @@ const ExampleComponent = () => {

_Parameters_

- _state_ `Object`: Data state.
- _state_ `BlockStoreState`: Data state.
- _blockName_ `string`: Block type name.

_Returns_

- `Array`: Array of child block names.
- `string[]`: Array of child block names.

### getCollections

Expand Down Expand Up @@ -346,11 +346,11 @@ const ExampleComponent = () => {

_Parameters_

- _state_ `Object`: Data state.
- _state_ `BlockStoreState`: Data state.

_Returns_

- `Object`: Collections list.
- `BlockCollection[]`: Collections list.

### getDefaultBlockName

Expand Down Expand Up @@ -381,11 +381,11 @@ const ExampleComponent = () => {

_Parameters_

- _state_ `Object`: Data state.
- _state_ `BlockStoreState`: Data state.

_Returns_

- `string?`: Default block name.
- `string|undefined`: Default block name.

### getDefaultBlockVariation

Expand Down Expand Up @@ -420,13 +420,13 @@ const ExampleComponent = () => {

_Parameters_

- _state_ `Object`: Data state.
- _state_ `BlockStoreState`: Data state.
- _blockName_ `string`: Block type name.
- _scope_ `[WPBlockVariationScope]`: Block variation scope name.
- _scope_ `BlockVariationScope=`: Block variation scope name.

_Returns_

- `?WPBlockVariation`: The default block variation.
- `BlockVariation|undefined`: The default block variation.

### getFreeformFallbackBlockName

Expand Down Expand Up @@ -460,11 +460,11 @@ const ExampleComponent = () => {

_Parameters_

- _state_ `Object`: Data state.
- _state_ `BlockStoreState`: Data state.

_Returns_

- `string?`: Name of the block for handling non-block content.
- `string|undefined`: Name of the block for handling non-block content.

### getGroupingBlockName

Expand Down Expand Up @@ -498,11 +498,11 @@ const ExampleComponent = () => {

_Parameters_

- _state_ `Object`: Data state.
- _state_ `BlockStoreState`: Data state.

_Returns_

- `string?`: Name of the block for handling the grouping of blocks.
- `string|undefined`: Name of the block for handling the grouping of blocks.

### getUnregisteredFallbackBlockName

Expand Down Expand Up @@ -536,11 +536,11 @@ const ExampleComponent = () => {

_Parameters_

- _state_ `Object`: Data state.
- _state_ `BlockStoreState`: Data state.

_Returns_

- `string?`: Name of the block for handling unregistered blocks.
- `string|undefined`: Name of the block for handling unregistered blocks.

### hasBlockSupport

Expand Down Expand Up @@ -572,8 +572,8 @@ const ExampleComponent = () => {

_Parameters_

- _state_ `Object`: Data state.
- _nameOrType_ `(string|Object)`: Block name or type object.
- _state_ `BlockStoreState`: Data state.
- _nameOrType_ `string|BlockType`: Block name or type object.
- _feature_ `string`: Feature to test.
- _defaultSupports_ `boolean`: Whether feature is supported by default if not explicitly defined.

Expand Down Expand Up @@ -611,7 +611,7 @@ const ExampleComponent = () => {

_Parameters_

- _state_ `Object`: Data state.
- _state_ `BlockStoreState`: Data state.
- _blockName_ `string`: Block type name.

_Returns_
Expand Down Expand Up @@ -653,7 +653,7 @@ const ExampleComponent = () => {

_Parameters_

- _state_ `Object`: Data state.
- _state_ `BlockStoreState`: Data state.
- _blockName_ `string`: Block type name.

_Returns_
Expand Down Expand Up @@ -696,13 +696,13 @@ const ExampleComponent = () => {

_Parameters_

- _state_ `Object`: Blocks state.
- _nameOrType_ `(string|Object)`: Block name or type object.
- _state_ `BlockStoreState`: Blocks state.
- _nameOrType_ `string|BlockType`: Block name or type object.
- _searchTerm_ `string`: Search term by which to filter.

_Returns_

- `Object[]`: Whether block type matches search term.
- `boolean`: Whether block type matches search term.

<!-- END TOKEN(Autogenerated selectors|../../../packages/blocks/src/store/selectors.js) -->

Expand Down
1 change: 1 addition & 0 deletions packages/block-editor/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
{ "path": "../a11y" },
{ "path": "../api-fetch" },
{ "path": "../blob" },
{ "path": "../blocks" },
{ "path": "../components" },
{ "path": "../compose" },
{ "path": "../data" },
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
{ "path": "../autop" },
{ "path": "../blob" },
{ "path": "../block-editor" },
{ "path": "../blocks" },
{ "path": "../components" },
{ "path": "../compose" },
{ "path": "../core-data" },
Expand Down
Loading
Loading