microsoft/vscode

[semantic][typescript] Constants with function type should be rendered as functions

IllusionMH opened this issue · 3 comments

Issue Type: Bug

If function is declared as const + arrow function it will be hightlighted as variable in editor, but as function in hover.

image

Is it expected behavior?

/cc @aeschli

VS Code version: Code - Insiders 1.42.0-insider (3c6f6af, 2020-01-27T05:27:06.595Z)
OS version: Windows_NT x64 10.0.18363

System Info
Item Value
CPUs Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz (12 x 3192)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
protected_video_decode: enabled
rasterization: enabled
skia_renderer: disabled_off
surface_control: disabled_off
surface_synchronization: enabled_on
video_decode: enabled
viz_display_compositor: enabled_on
viz_hit_test_surface_layer: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) undefined
Memory (System) 31.72GB (15.05GB free)
Process Argv
Screen Reader no
VM 0%
Extensions: none

In general, with semantic highlighting there will be difference between code in the editor and code snippets in hovers the's no semantic resultion possible in hovers (lack of context).

The sample that you show is interesting, and not really related to semantic information. The TypeScript TextMate grammar classified fn as a function, but semantic highlighting calls is a variable. So basically the type of the variable is used to figure out that it is a function.
I will fix this in the semantic highlighting code.

So basically the type of the variable is used to figure out that it is a function.

Looks like this is only working with variables, and interesting that TS doesn't highlight properties with arrow functions.
image

I will fix this in the semantic highlighting code.

So constants with function type will be highlighted as functions (yellow)? That would be awesome!

BTW, TS doesn't highlight unions as function even if all union members are function types 😢
image