Skip to content

Intellisense doesn't show type info about array index access on hoverΒ #59696

Closed as not planned

Description

@lionel-rowe

πŸ” Search Terms

intellisense, array, array index access, array square bracket access, hover

βœ… Viability Checklist

⭐ Suggestion

Array index access, e.g. arr[0], to show type info when hovering over the index.

πŸ“ƒ Motivating Example

const arr = [0, 1]

arr[0] // πŸ’₯ no hover. Expected "(property) 0: number" or "(property) 0?: number | undefined" with `noUncheckedIndexedAccess`
arr['1'] // πŸ’₯ no hover. Expected "(property) 1: number" or "(property) 1?: number | undefined" with `noUncheckedIndexedAccess`
arr['0'] // πŸ’₯ no hover. Expected "(property) 0: number" or "(property) 0?: number | undefined" with `noUncheckedIndexedAccess`
arr[1] // πŸ’₯ no hover. Expected "(property) 1: number" or "(property) 1?: number | undefined" with `noUncheckedIndexedAccess`
arr[2] // πŸ’₯ no hover. Expected "(property) 2: number" or "(property) 2?: number | undefined" with `noUncheckedIndexedAccess`

// for comparison
const obj = { 0: 0, '1': 1, key: 2 }
const tuple = [0, 1] as const
const extendedArr = Object.assign([0, 1] , { key: 2 })

obj.key // βœ… ok
obj['key'] // βœ… ok
obj[0] // βœ… ok
obj['1'] // βœ… ok
obj['0'] // βœ… ok
obj[1] // βœ… ok

tuple[0] // βœ… ok
tuple['1'] // βœ… ok
tuple['0'] // βœ… ok
tuple[1] // βœ… ok
tuple[2] // βœ… ok (fails type check as expected)

extendedArr.key // βœ… ok
extendedArr['key'] // βœ… ok
extendedArr[0] // πŸ’₯ no hover
extendedArr['1'] // πŸ’₯ no hover
extendedArr['0'] // πŸ’₯ no hover
extendedArr[1] // πŸ’₯ no hover

πŸ’» Use Cases

  1. What do you want to use this for?
    • DX/quality of life improvement
  2. What shortcomings exist with current approaches?
    • Less good DX
  3. What workarounds are you using in the meantime?
    • N/A

Activity

  1. jcalz commented on Aug 20, 2024

    @jcalz
    Contributor

    Looks like #58908

  2. typescript-bot commented on Aug 23, 2024

    @typescript-bot
    Contributor

    This issue has been marked as "Duplicate" and has seen no recent activity. It has been automatically closed for house-keeping purposes.

  3. locked as resolved and limited conversation to collaborators on Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions