TanStack / TanStack/form

Allow optional arrays to have array methods

Open
#1,588 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: enhancement v1 v2
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.