microsoft / microsoft/TypeScript

REOPEN: Classes that extend other Classes are not properly parsed by the JS Editor

Open
#54,953 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Needs More Info
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

Type: Bug

It seems if you have a class (e,g. AgentActivity) which extends another class (e.g., Activity) and you import the extended class (AgentActivity) into JS code, the editor initially fails to recognize the class as a class object until a change is made above the import, even if the change is to retype a colon.
Once the change is made, the class import turns green and it's methods are recognized in the body of the code.
This only lasts until the JS code file is reloaded for editing at some later time, whereupon the same problem recurs every time.

Sample code segment:

// Database
const BusinessUnit = require('../db/BusinessUnit');
const Activity = require('../db/Activity');
const AgentActivity = require('../db/AgentActivity');
const TimedActivity = require('../db/TimedActivity');
Note: AgentActivity extends Activity but shows in blue, and any attempt to use F12 (go to definition) on any of its methods results in a 'No Definition found for xxx' error. The rest of the classes are the correct green.

If I retype the colon or make any textual change in any line above the AgentActivity include, it turns green and its methods are now recognized in the JS code referencing it.

I cannot recreate this by simply creating classes, but I can demonstrate the issue by way of a screen recording. It is attached.
You'll need to unzip it. It is an MP4 file.

First I highlight that the Class name is not green in the body of the code when it is instantiated.
I attempt to use F12 to go to that method being used - it fails.
I then scroll to the Class import and show it is also not green.
I then add a single space at the end of a line above it.
I show the class name has now turned green.
I scroll back to the body of the code, note the Class name is now green here too.
I show I can now use the F12 key successfully.

VS Code version: Code 1.79.2 (695af097c7bd098fbf017ce3ac85e09bbc5dda06, 2023-06-14T08:57:04.379Z)
OS version: Windows_NT x64 10.0.22621
Modes:

System Info
Item Value
CPUs Intel(R) Core(TM) i7-9850H CPU @ 2.60GHz (12 x 2592)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
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
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) undefined
Memory (System) 31.79GB (14.48GB free)
Process Argv --crash-reporter-id 0d2f66ee-101b-4d7e-946b-87ab844b5438
Screen Reader no
VM 50%
Extensions (19)
Extension Author (truncated) Version
cform aws 0.0.24
vscode-eslint dba 2.4.2
vscode-firefox-debug fir 2.9.8
cloudcode goo 1.21.8
vscode-docker ms- 1.25.2
vscode-kubernetes-tools ms- 1.3.13
remote-containers ms- 0.299.0
remote-wsl ms- 0.79.5
live-server ms- 0.4.8
java red 1.20.0
vscode-yaml red 1.13.0
snyk-vulnerability-scanner sny 1.21.0
intellicode-api-usage-examples Vis 0.2.7
vscodeintellicode Vis 1.2.30
vscode-java-debug vsc 0.52.0
vscode-java-dependency vsc 0.23.0
vscode-java-pack vsc 0.25.12
vscode-java-test vsc 0.39.0
vscode-maven vsc 0.41.0
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
vserr242:30382549
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscoreces:30445986
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593cf:30376535
pythonvs932:30410667
py29gd2263:30776702
vsclangdf:30486550
c4g48928:30535728
dsvsc012:30540252
pynewext54:30695312
azure-dev_surveyone:30548225
3biah626:30602489
pyind779:30671433
f6dab269:30613381
pythonsymbol12:30671437
showlangstatbar:30737416
vsctsb:30748421
pythonms35:30701012
03d35959:30757346
7ij38806:30736111
pythonfmttext:30731395
pythoncmvfstrcf:30756944
fixshowwlkth:30771522
hideindicator:30766889
pythongtdpath:30769146
bgfeh915:30780428
pythonnosmt12:30779714
pythonidxpt:30784022
pythonnoceb:30776495

VisualStudioEditorClassFail.zip

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by unpacking VisualStudioEditorClassFail.zip and reproducing the behavior described with the AgentActivity, Activity, and require examples in VS Code 1.79.2. Trace the JavaScript editor's handling of imported classes and inheritance, then verify that method navigation works after reopening the file without requiring an unrelated edit.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.