Skip to content

Paths: Fix behavior with tuples containing optional elements with a rest element#1346

Merged
sindresorhus merged 1 commit intomainfrom
fix/paths-with-optional-rest-element-arrays
Feb 4, 2026
Merged

Paths: Fix behavior with tuples containing optional elements with a rest element#1346
sindresorhus merged 1 commit intomainfrom
fix/paths-with-optional-rest-element-arrays

Conversation

@som-sm
Copy link
Collaborator

@som-sm som-sm commented Feb 3, 2026

Currently Paths fails when instantiated with tuple containing optional elements with a rest element. For example, Paths<[({a: 1})?, ...string[]]> currently returns number | `${number}` | `${number}.a`, but should instead return number | `${number}` | '0.a'. This fails because the StaticPartOfArray and VariablePartOfArray utilities don't work properly with such tuples.

This PR fixes this issue by simply removing the array branch, arrays don't require any special handling.

@som-sm som-sm requested a review from sindresorhus February 3, 2026 17:24
Repository owner deleted a comment from claude bot Feb 3, 2026
@som-sm som-sm force-pushed the fix/paths-with-optional-rest-element-arrays branch from 3c10ce4 to 742ff7d Compare February 3, 2026 17:36
Repository owner deleted a comment from claude bot Feb 3, 2026
@sindresorhus sindresorhus merged commit 7c82a21 into main Feb 4, 2026
6 checks passed
@sindresorhus sindresorhus deleted the fix/paths-with-optional-rest-element-arrays branch February 4, 2026 04:32
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