Javascript function type inference breaks across a property accessor but not a function call #60600
Labels
Experience Enhancement
Noncontroversial enhancements
Help Wanted
You can do this
Suggestion
An idea for TypeScript
Milestone
Type: Bug
I am writing a typescript declaration file
declarations.d.ts
that describes some interfaces and a global object. The declarations will be use to assist JavaScript developers that are writing script for an embedded v8 engine that offers global objects like the one being described.There is a global variable
Global
of interface typeSomeGlobal
, which in turn has a propertysomeType
of interface typeSomeType
, and finallySomeType
has acallback
property of type function like(other:OtherType) => void
. Here is the entire file:declarations.d.ts
and the
jsconfig.json
being used to ensure that code in main.js can see these types:From here on, working a in
main.js
that looks like this:In VSCode when you attempt to assign the
callback
property ofSomeType
and open the parentheses to start building the arrow function like so:I would expect to see autocomplete help like
callback(other: OtherType): void
, prompting me to complete the statement like:But this is not what happens. If I hover over
callback
VS will display the appropriate signature for the property(property) SomeType.callback: (other: OtherType) => void
, but inside the arrow function param list or function body, theother
param just shows up as typeany
.What's interesting is that if I go through a function call instead of a property:
Then there is correct function type inference for
callback
and I get the intellisense autocomplete you'd expect.Am I just missing something silly here, or have I found a bug?
I have attached the 3 demo files for you to inspect. Any help would be most appreciated!
VS Code version: Code 1.95.3 (f1a4fb101478ce6ec82fe9627c43efbf9e98c813, 2024-11-13T14:50:04.152Z)
OS version: Windows_NT x64 10.0.22635
Modes:
System Info
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Extensions (57)
A/B Experiments
tssandbox.zip
The text was updated successfully, but these errors were encountered: