Skip to content

Commit

Permalink
Fix typings for EditorComponentField (#7160)
Browse files Browse the repository at this point in the history
* fix: make EditorComponentField type handle widget='list' correctly

* fix: make field and fields optional for widget='list'

---------

Co-authored-by: Anze Demsar <anze.demsar@p-m.si>
  • Loading branch information
mathiasandresen and demshy committed Mar 28, 2024
1 parent 85c92f0 commit 4262b63
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions packages/decap-cms-core/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -409,19 +409,24 @@ declare module 'decap-cms-core' {
config: CmsConfig;
}

export interface EditorComponentField {
name: string;
label: string;
widget: string;
/**
* Used if widget === "list" to create a flat array
*/
field: EditorComponentField;
/**
* Used if widget === "list" to create an array of objects
*/
fields: EditorComponentField[];
}
export type EditorComponentField =
| ({
name: string;
label: string;
} & {
widget: Omit<string, 'list'>;
})
| {
widget: 'list';
/**
* Used if widget === "list" to create a flat array
*/
field?: EditorComponentField;
/**
* Used if widget === "list" to create an array of objects
*/
fields?: EditorComponentField[];
};

export interface EditorComponentOptions {
id: string;
Expand Down

0 comments on commit 4262b63

Please sign in to comment.