-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f65f07b
commit 650e0cd
Showing
3 changed files
with
33 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,51 @@ | ||
import type { AnyRegularField, SliceField } from "./types"; | ||
|
||
export type SharedSliceVariationBase<Variation extends string = string> = { | ||
variation: Variation; | ||
version: string; | ||
}; | ||
|
||
/** | ||
* A shared Slice variation. Content is in the `primary` and `items` properties. | ||
*/ | ||
export type SharedSliceVariationWithPrimaryAndItems< | ||
Variation = string, | ||
PrimaryFields extends Record<string, AnyRegularField> = Record< | ||
Variation extends string = string, | ||
// SliceField is used to support a top-level SharedSliceVariation type. | ||
// It must support `AnyRegularField` and `SliceField`. | ||
PrimaryFields extends Record<string, SliceField> = Record< | ||
string, | ||
AnyRegularField | ||
>, | ||
ItemsFields extends Record<string, AnyRegularField> = Record< | ||
string, | ||
AnyRegularField | ||
>, | ||
> = Omit<SharedSliceVariation<Variation, PrimaryFields, ItemsFields>, "data">; | ||
> = SharedSliceVariationBase<Variation> & { | ||
primary: PrimaryFields; | ||
items: ItemsFields[]; | ||
}; | ||
|
||
/** | ||
* A shared Slice variation. Content is in the `data` property. | ||
*/ | ||
export type SharedSliceVariationWithData< | ||
Variation = string, | ||
Variation extends string = string, | ||
Fields extends Record<string, SliceField> = Record<string, SliceField>, | ||
> = Omit<SharedSliceVariation<Variation, Fields>, "primary" | "items">; | ||
> = SharedSliceVariationBase<Variation> & { | ||
variation: Variation; | ||
version: string; | ||
data: Fields; | ||
}; | ||
|
||
/** | ||
* A shared Slice variation. | ||
*/ | ||
export interface SharedSliceVariation< | ||
Variation = string, | ||
export type SharedSliceVariation< | ||
Variation extends string = string, | ||
Fields extends Record<string, SliceField> = Record<string, SliceField>, | ||
ItemsFields extends Record<string, AnyRegularField> = Record< | ||
string, | ||
AnyRegularField | ||
>, | ||
> { | ||
variation: Variation; | ||
version: string; | ||
data: Fields; | ||
primary: Fields; | ||
items: ItemsFields[]; | ||
} | ||
> = SharedSliceVariationWithData<Variation, Fields> & | ||
SharedSliceVariationWithPrimaryAndItems<Variation, Fields, ItemsFields>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters