Skip to content

Commit

Permalink
Increase specificity of TypeScript signatures in core-data selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
adamziel committed Jun 10, 2022
1 parent a0774c4 commit 5e389ac
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 86 deletions.
62 changes: 31 additions & 31 deletions docs/reference-guides/data/data-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ _Parameters_
- _state_ `State`: Data state.
- _action_ `string`: Action to check. One of: 'create', 'read', 'update', 'delete'.
- _resource_ `string`: REST resource to check, e.g. 'media' or 'posts'.
- _id_ `GenericRecordKey`: Optional ID of the rest resource to check.
- _id_ `unknown`: Optional ID of the rest resource to check.

_Returns_

Expand All @@ -39,9 +39,9 @@ Calling this may trigger an OPTIONS request to the REST API via the
_Parameters_

- _state_ `State`: Data state.
- _kind_ `Kind`: Entity kind.
- _name_ `Name`: Entity name.
- _recordId_ `GenericRecordKey`: Record's id.
- _kind_ `K`: Entity kind.
- _name_ `N`: Entity name.
- _recordId_ `KeyOf< K, N >`: Record's id.

_Returns_

Expand Down Expand Up @@ -69,9 +69,9 @@ Returns the autosave for the post and author.
_Parameters_

- _state_ `State`: State tree.
- _postType_ `string`: The type of the parent post.
- _postId_ `GenericRecordKey`: The id of the parent post.
- _authorId_ `GenericRecordKey`: The id of the author.
- _postType_ `Post[ 'type' ]`: The type of the parent post.
- _postId_ `Post[ 'id' ]`: The id of the parent post.
- _authorId_ `User[ 'id' ]`: The id of the author.

_Returns_

Expand All @@ -87,8 +87,8 @@ author for each post.
_Parameters_

- _state_ `State`: State tree.
- _postType_ `string`: The type of the parent post.
- _postId_ `GenericRecordKey`: The id of the parent post.
- _postType_ `Post[ 'type' ]`: The type of the parent post.
- _postId_ `Post[ 'id' ]`: The id of the parent post.

_Returns_

Expand Down Expand Up @@ -128,7 +128,7 @@ _Parameters_

_Returns_

- `any`: The current theme.
- The current theme.

### getCurrentUser

Expand All @@ -155,7 +155,7 @@ _Parameters_

_Returns_

- `EntityRecord | undefined`: The entity record, merged with its edits.
- `EntityRecordOf< K, N > | undefined`: The entity record, merged with its edits.

### getEmbedPreview

Expand Down Expand Up @@ -183,7 +183,7 @@ _Parameters_

_Returns_

- `Array< any >`: Array of entities with config matching kind.
- `AnyEntityConfig[]`: Array of entities with config matching kind.

### getEntitiesConfig

Expand All @@ -196,7 +196,7 @@ _Parameters_

_Returns_

- `Array< any >`: Array of entities with config matching kind.
- `AnyEntityConfig[]`: Array of entities with config matching kind.

### getEntity

Expand All @@ -212,7 +212,7 @@ _Parameters_

_Returns_

- `any`: Entity config
- Entity config

### getEntityConfig

Expand All @@ -226,7 +226,7 @@ _Parameters_

_Returns_

- `any`: Entity config
- `Optional< AnyEntityConfig >`: Entity config

### getEntityRecord

Expand Down Expand Up @@ -259,7 +259,7 @@ _Parameters_

_Returns_

- `Optional< any >`: The entity record's edits.
- `Optional< Partial< EntityRecordOf< K, N > > >`: The entity record's edits.

### getEntityRecordNonTransientEdits

Expand All @@ -278,7 +278,7 @@ _Parameters_

_Returns_

- `Optional< any >`: The entity record's non transient edits.
- `Partial< EntityRecordOf< K, N > >`: The entity record's non transient edits.

### getEntityRecords

Expand All @@ -302,9 +302,9 @@ Returns the specified entity record's last delete error.
_Parameters_

- _state_ `State`: State tree.
- _kind_ `Kind`: Entity kind.
- _name_ `Name`: Entity name.
- _recordId_ `GenericRecordKey`: Record ID.
- _kind_ `K`: Entity kind.
- _name_ `N`: Entity name.
- _recordId_ `KeyOf< K, N >`: Record ID.

_Returns_

Expand All @@ -317,9 +317,9 @@ Returns the specified entity record's last save error.
_Parameters_

- _state_ `State`: State tree.
- _kind_ `Kind`: Entity kind.
- _name_ `Name`: Entity name.
- _recordId_ `GenericRecordKey`: Record ID.
- _kind_ `K`: Entity kind.
- _name_ `N`: Entity name.
- _recordId_ `KeyOf< K, N >`: Record ID.

_Returns_

Expand Down Expand Up @@ -452,8 +452,8 @@ Returns true if the REST request for autosaves has completed.
_Parameters_

- _state_ `State`: State tree.
- _postType_ `string`: The type of the parent post.
- _postId_ `GenericRecordKey`: The id of the parent post.
- _postType_ `Post[ 'type' ]`: The type of the parent post.
- _postId_ `Post[ 'id' ]`: The id of the parent post.

_Returns_

Expand Down Expand Up @@ -492,9 +492,9 @@ Returns true if the specified entity record is autosaving, and false otherwise.
_Parameters_

- _state_ `State`: State tree.
- _kind_ `Kind`: Entity kind.
- _name_ `Name`: Entity name.
- _recordId_ `GenericRecordKey`: Record ID.
- _kind_ `K`: Entity kind.
- _name_ `N`: Entity name.
- _recordId_ `KeyOf< K, N >`: Record ID.

_Returns_

Expand All @@ -507,9 +507,9 @@ Returns true if the specified entity record is deleting, and false otherwise.
_Parameters_

- _state_ `State`: State tree.
- _kind_ `Kind`: Entity kind.
- _name_ `Name`: Entity name.
- _recordId_ `GenericRecordKey`: Record ID.
- _kind_ `K`: Entity kind.
- _name_ `N`: Entity name.
- _recordId_ `KeyOf< K, N >`: Record ID.

_Returns_

Expand Down
62 changes: 31 additions & 31 deletions packages/core-data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ _Parameters_
- _state_ `State`: Data state.
- _action_ `string`: Action to check. One of: 'create', 'read', 'update', 'delete'.
- _resource_ `string`: REST resource to check, e.g. 'media' or 'posts'.
- _id_ `GenericRecordKey`: Optional ID of the rest resource to check.
- _id_ `unknown`: Optional ID of the rest resource to check.

_Returns_

Expand All @@ -286,9 +286,9 @@ Calling this may trigger an OPTIONS request to the REST API via the
_Parameters_

- _state_ `State`: Data state.
- _kind_ `Kind`: Entity kind.
- _name_ `Name`: Entity name.
- _recordId_ `GenericRecordKey`: Record's id.
- _kind_ `K`: Entity kind.
- _name_ `N`: Entity name.
- _recordId_ `KeyOf< K, N >`: Record's id.

_Returns_

Expand Down Expand Up @@ -316,9 +316,9 @@ Returns the autosave for the post and author.
_Parameters_

- _state_ `State`: State tree.
- _postType_ `string`: The type of the parent post.
- _postId_ `GenericRecordKey`: The id of the parent post.
- _authorId_ `GenericRecordKey`: The id of the author.
- _postType_ `Post[ 'type' ]`: The type of the parent post.
- _postId_ `Post[ 'id' ]`: The id of the parent post.
- _authorId_ `User[ 'id' ]`: The id of the author.

_Returns_

Expand All @@ -334,8 +334,8 @@ author for each post.
_Parameters_

- _state_ `State`: State tree.
- _postType_ `string`: The type of the parent post.
- _postId_ `GenericRecordKey`: The id of the parent post.
- _postType_ `Post[ 'type' ]`: The type of the parent post.
- _postId_ `Post[ 'id' ]`: The id of the parent post.

_Returns_

Expand Down Expand Up @@ -375,7 +375,7 @@ _Parameters_

_Returns_

- `any`: The current theme.
- The current theme.

### getCurrentUser

Expand All @@ -402,7 +402,7 @@ _Parameters_

_Returns_

- `EntityRecord | undefined`: The entity record, merged with its edits.
- `EntityRecordOf< K, N > | undefined`: The entity record, merged with its edits.

### getEmbedPreview

Expand Down Expand Up @@ -430,7 +430,7 @@ _Parameters_

_Returns_

- `Array< any >`: Array of entities with config matching kind.
- `AnyEntityConfig[]`: Array of entities with config matching kind.

### getEntitiesConfig

Expand All @@ -443,7 +443,7 @@ _Parameters_

_Returns_

- `Array< any >`: Array of entities with config matching kind.
- `AnyEntityConfig[]`: Array of entities with config matching kind.

### getEntity

Expand All @@ -459,7 +459,7 @@ _Parameters_

_Returns_

- `any`: Entity config
- Entity config

### getEntityConfig

Expand All @@ -473,7 +473,7 @@ _Parameters_

_Returns_

- `any`: Entity config
- `Optional< AnyEntityConfig >`: Entity config

### getEntityRecord

Expand Down Expand Up @@ -506,7 +506,7 @@ _Parameters_

_Returns_

- `Optional< any >`: The entity record's edits.
- `Optional< Partial< EntityRecordOf< K, N > > >`: The entity record's edits.

### getEntityRecordNonTransientEdits

Expand All @@ -525,7 +525,7 @@ _Parameters_

_Returns_

- `Optional< any >`: The entity record's non transient edits.
- `Partial< EntityRecordOf< K, N > >`: The entity record's non transient edits.

### getEntityRecords

Expand All @@ -549,9 +549,9 @@ Returns the specified entity record's last delete error.
_Parameters_

- _state_ `State`: State tree.
- _kind_ `Kind`: Entity kind.
- _name_ `Name`: Entity name.
- _recordId_ `GenericRecordKey`: Record ID.
- _kind_ `K`: Entity kind.
- _name_ `N`: Entity name.
- _recordId_ `KeyOf< K, N >`: Record ID.

_Returns_

Expand All @@ -564,9 +564,9 @@ Returns the specified entity record's last save error.
_Parameters_

- _state_ `State`: State tree.
- _kind_ `Kind`: Entity kind.
- _name_ `Name`: Entity name.
- _recordId_ `GenericRecordKey`: Record ID.
- _kind_ `K`: Entity kind.
- _name_ `N`: Entity name.
- _recordId_ `KeyOf< K, N >`: Record ID.

_Returns_

Expand Down Expand Up @@ -699,8 +699,8 @@ Returns true if the REST request for autosaves has completed.
_Parameters_

- _state_ `State`: State tree.
- _postType_ `string`: The type of the parent post.
- _postId_ `GenericRecordKey`: The id of the parent post.
- _postType_ `Post[ 'type' ]`: The type of the parent post.
- _postId_ `Post[ 'id' ]`: The id of the parent post.

_Returns_

Expand Down Expand Up @@ -739,9 +739,9 @@ Returns true if the specified entity record is autosaving, and false otherwise.
_Parameters_

- _state_ `State`: State tree.
- _kind_ `Kind`: Entity kind.
- _name_ `Name`: Entity name.
- _recordId_ `GenericRecordKey`: Record ID.
- _kind_ `K`: Entity kind.
- _name_ `N`: Entity name.
- _recordId_ `KeyOf< K, N >`: Record ID.

_Returns_

Expand All @@ -754,9 +754,9 @@ Returns true if the specified entity record is deleting, and false otherwise.
_Parameters_

- _state_ `State`: State tree.
- _kind_ `Kind`: Entity kind.
- _name_ `Name`: Entity name.
- _recordId_ `GenericRecordKey`: Record ID.
- _kind_ `K`: Entity kind.
- _name_ `N`: Entity name.
- _recordId_ `KeyOf< K, N >`: Record ID.

_Returns_

Expand Down
Loading

0 comments on commit 5e389ac

Please sign in to comment.