You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 type SomeGlobal, which in turn has a property someType of interface type SomeType, and finally SomeType has a callback property of type function like (other:OtherType) => void. Here is the entire file: declarations.d.ts
interfaceOtherType{stringProperty: string;}interfaceSomeType{callback: (other:OtherType)=>void;}interfaceSomeGlobal{someType: SomeType;getSomeType(): SomeType;}declarevarGlobal: SomeGlobal;// This is not part of the declarations, it's here to show you that the type of `o` is properly inferred through the property accessor `someType`Global.someType.callback=(o)=>{o.stringProperty}
and the jsconfig.json being used to ensure that code in main.js can see these types:
In VSCode when you attempt to assign the callback property of SomeType and open the parentheses to start building the arrow function like so:
Global.someType.callback=(
I would expect to see autocomplete help like callback(other: OtherType): void, prompting me to complete the statement like:
Global.someType.callback=(other)=>{/* do something*/};
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, the other param just shows up as type any.
What's interesting is that if I go through a function call instead of a property:
Global.getSomeType().callback=(
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
Item
Value
CPUs
Intel(R) Core(TM) i9-7900X CPU @ 3.30GHz (20 x 3312)
Thanks for the reassignment @mjbvz. FWIW, I can confirm that this works properly in WebStorm, so it does seem to be an issue with VSCode or its built-in TypeScript or JavaScript extension.
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: