Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RA-OSS-20 - Some Inputs with choices in their props do not accept ReadonlyArray<T> #9162

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

gitstart
Copy link
Contributor

@gitstart gitstart commented Aug 3, 2023

ISSUE


This code was written and reviewed by GitStart Community. Growing great engineers, one PR at a time.

Co-authored-by: passy4ucj <[email protected]>
Co-authored-by: gitstart_bot <[email protected]>
Copy link
Contributor

@slax57 slax57 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not fix the issue.

Tested in the simple example with a code adapted from the code given in #9155 , and I still see the error.

Co-authored-by: Azerii <[email protected]>
@slax57
Copy link
Contributor

slax57 commented Oct 26, 2023

Thanks for this updated version.

I must admit I'm a bit reluctant to accept this solution, because of all the as any[] it requires.

An alternative solution, that would be cleaner IMO, would be to use generic types in this manner:

interface ChoicesProps <T = any[]> {
    choices?: T extends Array<any> ? T : T extends ReadonlyArray<any> ? T : "must be Array or ReadonlyArray";
}

However this would also require propagating the type to inner layers of the code. So it may lead to many changed files...

You can give it a try if you will, but I must remind that, for the reasons explained here, and because it is so easy to fix in user-land, we are not willing to invest too much time on resolving this issue in case it starts becoming too complex.

@gitstart
Copy link
Contributor Author

gitstart commented Nov 8, 2023

@slax57 we tried another fix can you check it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants