formio / formio.js

JavaScript powered Forms with JSON Form Builder
https://formio.github.io/formio.js
MIT License
1.89k stars 1.06k forks source link

Typing issue with emptyValue property on Component #5481

Open hisuwh opened 9 months ago

hisuwh commented 9 months ago

I'm creating a custom component and need to override emptyValue to set the default to an array for my component (as per the example: https://help.form.io/developers/form-development/custom-components#checkmatrix-component).

However, Typescript is giving me errors:

image

I can resolve the first one by saying return ([] as any);

But the only way around the second one is use // @ts-ignore or equiv which I don't like. Looking at the source I can see this is a property in the base so there must be an issue in the generated types. https://github.com/formio/formio.js/blob/master/src/components/_classes/component/Component.js#L2443

Jameskmonger commented 9 months ago

It looks like all the accessors are actually declared as just properties in the types. If there is no associated set, then they are also marked as readonly.

In this instance, it is declared as readonly emptyValue: null; whereas we would need it declared as get emptyValue(): null; (or, ideally, to fix both issues, get emptyValue(): any;)

Sidiro23 commented 2 months ago

Thank you for your contribution. As this issue has been inactive for over 90 days, I will close it for now. If you wish to reopen the issue, please respond and we can resume the triage process.

hisuwh commented 2 months ago

@Sidiro23 this is inactive because no one from formio has acknowledged it. We would like this resolved please.

lane-formio commented 2 months ago

@hisuwh Apologies, this ended up in the wrong queue. Re-opening the issue.

daneformio commented 1 month ago

We've created a ticket for our dev team to review. In the meantime, we would be happy to review a pull request for this issue should one be created. Ticket for internal tracking: FIO-9131