decaporg / decap-cms

A Git-based CMS for Static Site Generators
https://decapcms.org
MIT License
17.65k stars 3.02k forks source link

Fix typings for EditorComponentField #7160

Closed mathiasandresen closed 3 months ago

mathiasandresen commented 3 months ago

Summary It was not possible for me to add new widgets with correct typing, since I was required to set field and fields for non 'list' widgets. So I modified the types to be a discriminated union, that only allows setting field and field when widget is equal to 'list'.

image

Test plan

Checklist

Please add a x inside each checkbox:

A picture of a cute animal (not mandatory but encouraged)

frankiereyes commented 3 months ago

I just ran into this same issue when referencing the documentation for registering an editor component: https://decapcms.org/docs/custom-widgets/

chrisleyva commented 3 months ago

@mathiasandresen great fix! 👍 I also ran into this issue.

demshy commented 3 months ago

released as decap-cms@3.1.5