Allow optional arrays to have array methods
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 6.7k
- Forks
- 682
- Avg merge
- 5d 18h
- Merged PRs (30d)
- 7
Description
Much of my data is optional as I'm building a content creation form for TTRPG systems. This is a fairly complex form and there's a lot of variety even within a group of what's actually required. And rather than filling in empty arrays automatically to just have to disregard them when the data is submitted, I leave them optional. As of right now, when trying to use the removeFieldValue method, it will types the optional field as never.
A work around is to a copy of the array with the value removed and then using setFieldValue.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing removeFieldValue with an optional array field in a TypeScript form and compare its typing with setFieldValue, which is the reported workaround. Done means optional arrays retain usable array-method types instead of being typed as never when removing a value.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100