Skip to content

Commit

Permalink
[field] Add array item metadata type, add 'items' to array diff compo…
Browse files Browse the repository at this point in the history
…nent props
  • Loading branch information
rexxars committed Oct 6, 2020
1 parent cae904a commit b33aab0
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/@sanity/field/src/diff/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ export type StringSegmentUnchanged = AgnosticStringSegmentUnchanged

export type ItemDiff = AgnosticItemDiff<Annotation>

/**
* Diff extensions for presentational concerns
*/
export interface ArrayItemMetadata {
fromType?: SchemaType
toType?: SchemaType
}

/**
* Diff components
*/
Expand All @@ -85,6 +93,7 @@ export type DiffProps<T extends Diff = Diff> = {
: T extends NumberDiff
? NumberSchemaType
: SchemaType
items?: T extends ArrayDiff ? ArrayItemMetadata[] : undefined
}

/**
Expand Down Expand Up @@ -112,10 +121,10 @@ export interface BooleanSchemaType extends BaseSchemaType {
jsonType: 'boolean'
}

export interface ArraySchemaType<T = unknown> extends BaseSchemaType {
export interface ArraySchemaType<V = unknown> extends BaseSchemaType {
jsonType: 'array'
of: Exclude<SchemaType, ArraySchemaType>[]
diffComponent?: DiffComponent<ArrayDiff<T>>
diffComponent?: DiffComponent<ArrayDiff<V>>
}

export interface ObjectField<T extends SchemaType = SchemaType> {
Expand Down

0 comments on commit b33aab0

Please sign in to comment.