Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaScript - No suggestions for object with number index without quotes. #120671

Closed
pixieaka opened this issue Apr 6, 2021 · 3 comments
Closed
Assignees
Labels
*as-designed Described behavior is as designed javascript JavaScript support issues

Comments

@pixieaka
Copy link

pixieaka commented Apr 6, 2021

  • VS Code Version: 1.55.0
  • OS Version: Windows 10 20h2

Steps to Reproduce:

2

Does this issue occur when all extensions are disabled?: Yes

@mjbvz mjbvz self-assigned this Apr 6, 2021
@mjbvz mjbvz added *as-designed Described behavior is as designed javascript JavaScript support issues labels Apr 6, 2021
@pixieaka
Copy link
Author

pixieaka commented Apr 6, 2021

@mjbvz But object with numeric indexes can access without quotes. Why suggestions doesn't support this case?

@mjbvz
Copy link
Collaborator

mjbvz commented Apr 7, 2021

The keys are strings. Yes JavaScript auto converts the bracketed value to a string, but that does not mean we want show IntelliSense suggesting to use a number literal here. As a more extreme example, consider:

const  b = { 5: 'xyz' }
b[{ toString: () => '5' }] // 'xyz'

Instead we show IntelliSense inside brackets when you start typing a string key:

Screen Shot 2021-04-06 at 5 48 24 PM

@github-actions github-actions bot locked and limited conversation to collaborators May 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*as-designed Described behavior is as designed javascript JavaScript support issues
Projects
None yet
Development

No branches or pull requests

3 participants
@mjbvz @pixieaka and others