Skip to content

Conversation

mimbrown
Copy link

@mimbrown mimbrown commented Jun 2, 2025

The types for nested arrays in the DeepKeys type seem definitely wrong to me. The type properly handles tuples, but not arrays of arbitrary length. For example, given this type:

DeepKeys<{
  foo: { bar: string }[];
}>

This currently resolves to "foo" | "foo.bar", which is unexpected. If we change the type to be a tuple (i.e. { bar: string }[] --> [{ bar: string }]), then we correctly get "foo" | "foo.0.bar".

This change updates the handling for arbitrary length arrays so that the above type will resolve to:

"foo" | `foo.${number}` | `foo.${number}.bar`

This puts the onus on the user to make sure the number is not out of range, but that seems reasonable to me.

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.

1 participant