Skip to content

Commit 5006e01

Browse files
committed
Distribute BlockInRequest<D> over D
Aligns BlockInRequest with BlockInNestedResponse so that, when D is a union of item-type definitions, the type expands into per-D variants instead of a single object whose internal fields carry the union. This restores type-narrowing on `attributes`, `relationships`, and the `__itemTypeId` discriminator when consumers pattern-match by item_type.
1 parent 84f6ead commit 5006e01

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

packages/cma-client/src/fieldTypes/single_block.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ export type NewBlockInRequest<
9393
* Also, 'meta' can always be omitted
9494
*/
9595
export type BlockInRequest<D extends ItemTypeDefinition = ItemTypeDefinition> =
96-
| UnchangedBlockInRequest
97-
| UpdatedBlockInRequest<D>
98-
| NewBlockInRequest<D>;
96+
D extends unknown
97+
? UnchangedBlockInRequest | UpdatedBlockInRequest<D> | NewBlockInRequest<D>
98+
: never;
9999

100100
export type BlockInNestedResponse<
101101
D extends ItemTypeDefinition = ItemTypeDefinition,

0 commit comments

Comments
 (0)