Fix ArrayField initialValue type: unknown[] instead of [unknown] - #497
Open
ZayanKhan-12 wants to merge 1 commit into
Open
Fix ArrayField initialValue type: unknown[] instead of [unknown]#497ZayanKhan-12 wants to merge 1 commit into
ZayanKhan-12 wants to merge 1 commit into
Conversation
The declared type [unknown] is a single-element tuple, so TypeScript rejected any ArrayField initialValue with more than one item, including the example from the docs (teslamotors#485). The type test only used a one-element array, which a tuple type accidentally accepts; it now uses two items so a regression fails the tsd run. Fixes teslamotors#485 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
#485:
ArrayField'sinitialValueprop is declared as[unknown]inindex.d.ts— a single-element tuple — so TypeScript rejects any initial value with more than one item:This rejects the exact usage shown in the ArrayField docs.
Changes
index.d.ts:initialValue?: [unknown]→initialValue?: unknown[], as suggested in the issue.index.test-d.tsx: the existing ArrayField type test used a one-element array, which a tuple type accidentally accepts — that's why this slipped through. It now uses a two-elementinitialValue, so reintroducing the tuple type fails thetsdrun.Verification
Compiling an assignment of a two-element array to
Props['initialValue']fails against the old declaration with the exact TS2322 error above and passes with the fix. (The full localnpx tsdrun reports 76 pre-existing "Cannot find namespace JSX" errors on unmodified master as well — an environment/@types/reactdrift unrelated to this change; the error count is identical before and after.)Fixes #485
🤖 Generated with Claude Code