microsoft / microsoft/TypeScript

False positive "Private field ... must be declared in an enclosing class."

Open
#63,159 3 comments 0 reactions 0 assignees View on GitHub
Bug Domain: LS: TSServer
Dominant language
Go
Stars
111k
Forks
14.3k
PR merge metrics
PR metrics pending

Description

Type: Bug

Create two copies of the file below (e.g. ab1.js and ab2.js), and open them in two tabs.

Actual: Observe whichever file you open second to show "Private field must be declared in an enclosing class" errors on `#p` call until you close the first file.

ab1.js / ab2.js:
```javascript
class A { static #p () { } constructor () { A.#p(); } }
class B { static #p () { } constructor () { B.#p(); } }
```

Expected: No errors in either file regardless of which are open or in what order.

Seems like some sort of cross-tab state pollution.

VS Code version: Code 1.109.2 (591199df409fbf59b4b52d5ad4ee0470152a9b31, 2026-02-10T20:18:23.520Z)
OS version: Linux x64 6.12.57+deb13-amd64
Modes:
Remote OS version: Linux x64 4.19.0-22-amd64
Remote OS version: Linux x64 4.19.0-22-amd64
Remote OS version: Linux x64 4.19.0-22-amd64

System Info

|Item|Value|
|---|---|
|CPUs|Intel(R) Core(TM) i5-7400 CPU @ 3.00GHz (4 x 3299)|
|GPU Status|2d_canvas: enabled
GPU0: VENDOR= 0x8086 [Google Inc. (Intel)], DEVICE=0x5912 [ANGLE (Intel, Mesa Intel(R) HD Graphics 630 (KBL GT2), OpenGL ES 3.2 Mesa 25.0.7-2)], DRIVER_VENDOR=Mesa, DRIVER_VERSION=25.0.7 *ACTIVE*
Machine model name:
Machine model version:
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
trees_in_viz: disabled_off
video_decode: enabled
video_encode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
webnn: disabled_off|
|Load (avg)|1, 1, 1|
|Memory (System)|11.60GB (2.00GB free)|
|Process Argv|--crash-reporter-id 97c901d7-5d55-4f8c-b33d-38997feaf33e|
|Screen Reader|no|
|VM|0%|
|DESKTOP_SESSION|plasma|
|XDG_CURRENT_DESKTOP|KDE|
|XDG_SESSION_DESKTOP|KDE|
|XDG_SESSION_TYPE|wayland|

|Item|Value|
|---|---|
|Remote|SSH: k1.kappacs.com|
|OS|Linux x64 4.19.0-22-amd64|
|CPUs|Pentium(R) Dual-Core CPU E5800 @ 3.20GHz (2 x 1217)|
|Memory (System)|3.82GB (0.84GB free)|
|VM|0%|

|Item|Value|
|---|---|
|Remote|SSH: k1.kappacs.com|
|OS|Linux x64 4.19.0-22-amd64|
|CPUs|Pentium(R) Dual-Core CPU E5800 @ 3.20GHz (2 x 1217)|
|Memory (System)|3.82GB (0.84GB free)|
|VM|0%|

|Item|Value|
|---|---|
|Remote|SSH: k1.kappacs.com|
|OS|Linux x64 4.19.0-22-amd64|
|CPUs|Pentium(R) Dual-Core CPU E5800 @ 3.20GHz (2 x 1217)|
|Memory (System)|3.82GB (0.84GB free)|
|VM|0%|
Extensions (5)

Extension|Author (truncated)|Version
---|---|---
kilo-code|kil|5.7.0
remote-ssh|ms-|0.122.0
remote-ssh-edit|ms-|0.87.0
remote-explorer|ms-|0.5.0
vim|vsc|1.32.4

A/B Experiments

```
vsliv368cf:30146710
vswsl492:30256859
binariesv615:30325510
nativeloc1:31344060
dwcopilot:31170013
dwoutputs:31242946
copilot_t_ci:31333650
e5gg6876:31282496
pythonrdcb7:31342333
6518g693:31463988
aj953862:31281341
b6b4d950:31327385
6abeh943:31336334
envsactivate1:31464700
cloudbuttont:31379625
aihoversummaries_f:31453033
42190218_ostrepl:31403339
use-responses-api:31390855
anonusage:31403420
ec5jj548:31422691
cp_cls_c_966_ss:31454199
4je02754:31463857
find_all_ref_in_bg_t:31453034
a5gib710:31434435
7a04d226_do_not_restore_last_panel_session:31438103
cp_cls_t_1081:31454832
a43f0575b:31442825
e9c30283:31461165
idci7584:31464702
edit_mode_hidden:31461530
nostats:31457175
864ei723_large_tool_results_to_disk:31460878
notips:31457203
chat:31457767

```

Contributor guide

Open the contributing guide

Research direction

Reproduce the diagnostic by opening two copies of the provided JavaScript file in separate tabs and compare the first and second file's errors. Trace the cross-tab state involved in reporting private-field diagnostics, then verify that neither file reports an error for its own `#p` call regardless of open order.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript, vscode
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.