microsoft / microsoft/TypeScript

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

Ouverte
#54,953 6 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Needs More Info
Langage dominant
Go
Étoiles
111k
Forks
14.4k
Merge moyen
1 j 19 h
PR mergées (30 j)
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

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par décompresser VisualStudioEditorClassFail.zip et reproduire le comportement décrit avec les exemples AgentActivity, Activity et require dans VS Code 1.79.2. Suivez ensuite la manière dont l’éditeur JavaScript gère les classes importées et l’héritage, puis vérifiez que la navigation vers les méthodes fonctionne après la réouverture du fichier sans nécessiter une modification sans rapport.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
javascript
Domaine
tooling
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
À clarifier
Accessibilité débutants
38/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.