microsoft / microsoft/TypeScript
Using classes in jsdoc comments results in different behaviors depending on how the class was required
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
TS Template added by @mjbvz
TypeScript Version: 3.9.1
Search Terms
- javascript
- jsdoc
Issue Type: Bug
I have a class Foo in a file deep in my project.
Everything works fine if I require it directly: intellisense understands that when I use Foo in my jsdoc comments, I mean that I want instances of Foo:

But if I require the same file through other files, intellisense thinks I want the Foo class:

I have created an example repo that reproduces the problem here:
https://github.com/gaelhameon/vscode-intellisense-issue
Is this the expected behavior ?
If it is, is there a way to have the "instance" behavior without having to require the file directly ?
Thanks in advance!
VS Code version: Code 1.45.0 (d69a79b73808559a91206d73d7717ff5f798f23c, 2020-05-07T16:18:48.860Z)
OS version: Windows_NT x64 10.0.18362
System Info
| Item | Value |
|---|---|
| CPUs | Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz (8 x 1800) |
| GPU Status | 2d_canvas: enabled flash_3d: enabled flash_stage3d: enabled flash_stage3d_baseline: enabled gpu_compositing: enabled multiple_raster_threads: enabled_on oop_rasterization: disabled_off protected_video_decode: enabled rasterization: enabled skia_renderer: disabled_off_ok video_decode: enabled viz_display_compositor: enabled_on viz_hit_test_surface_layer: disabled_off_ok webgl: enabled webgl2: enabled |
| Load (avg) | undefined |
| Memory (System) | 7.82GB (1.53GB free) |
| Process Argv | |
| Screen Reader | no |
| VM | 0% |
Extensions (5)
| Extension | Author (truncated) | Version |
|---|---|---|
| javascript-test-runner-reloaded | ale | 2.2.1 |
| vscode-eslint | dba | 2.1.5 |
| gitlens | eam | 10.2.1 |
| vscode-pull-request-github | Git | 0.16.0 |
| vscode-commitizen | Kni | 0.8.4 |
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked reproduction repository and compare the two require paths described in the issue under TypeScript 3.9.1. Trace how JSDoc resolves Foo when the class is required directly versus through other files, then verify the behavior against the reported VS Code setup. Done means the two import paths produce consistent instance-oriented IntelliSense, with a regression test covering the reproduction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100