microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
100.05k stars 12.37k forks source link

TS intellisense getting tripped on const object indexes #44041

Open qwelias opened 3 years ago

qwelias commented 3 years ago

TS Template added by @mjbvz

TypeScript Version: 4.4.0-dev.20210511

Search Terms


Issue Type: Bug

const a = {
    foo: 'foo',
} as const;

const c = {
    [a.foo]: 'foo',
} as const;

c.

Suggests: Screenshot from 2021-05-11 17-49-16 Screenshot from 2021-05-11 17-49-33 Yet type of c seems to be perfectly fine when hovered.

VS Code version: Code 1.55.2 (3c4e3df9e89829dce27b7b5c24508306b151f30d, 2021-04-13T09:37:02.931Z) OS version: Linux x64 5.11.16-arch1-1

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz (8 x 2100)| |GPU Status|2d_canvas: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
opengl: enabled_on
protected_video_decode: unavailable_off
rasterization: disabled_software
skia_renderer: enabled_on
video_decode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled| |Load (avg)|1, 1, 1| |Memory (System)|31.02GB (12.29GB free)| |Process Argv|. --no-sandbox| |Screen Reader|no| |VM|0%| |DESKTOP_SESSION|undefined| |XDG_CURRENT_DESKTOP|GNOME| |XDG_SESSION_DESKTOP|undefined| |XDG_SESSION_TYPE|tty|
Extensions (19) Extension|Author (truncated)|Version ---|---|--- terraform|4op|0.2.2 lit-html|bie|1.11.1 better-toml|bun|0.3.2 mustache|daw|1.1.1 vscode-eslint|dba|2.1.20 gitlens|eam|11.4.1 EditorConfig|Edi|0.16.4 RunOnSave|eme|0.2.0 plantuml|jeb|2.14.5 better-shellscript-syntax|jef|1.1.0 vscode-phpfmt|kok|1.0.30 theme-monokai-pro-vscode|mon|1.1.19 gitlink|qez|0.6.1 rust|rus|0.7.8 vscode-fileutils|sle|3.4.5 code-spell-checker|str|1.10.2 vcl|tho|0.1.2 shellcheck|tim|0.14.1 vscode-lldb|vad|1.6.3
Zzzen commented 3 years ago

Did you try a? It will convert c. to c[a] and let you change it to c[a.foo] which is how it's declared in c.

Zzzen commented 3 years ago

https://user-images.githubusercontent.com/6630042/118371160-d91eb400-b5dd-11eb-8324-1a877318a1ba.mp4

Currently, only the first identifier Symbol is displayed on the completion list. It would be more intuitive if the whole expression Symbol.iterator is provided.

qwelias commented 3 years ago

Would it convert to 'foo' if a is not in current scope?

Zzzen commented 3 years ago

To my surprise, it would.