microsoft / microsoft/TypeScript

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

未关闭
#63,159 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Bug Domain: LS: TSServer
主要语言
Go
星标
111k
派生
14.3k
平均合并
2 天 4 小时
30 天内合并 PR
132

描述

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

```

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

通过在不同标签页中打开所提供 JavaScript 文件的两个副本来重现该诊断,并比较第一个文件和第二个文件的错误。跟踪涉及报告私有字段诊断的跨标签页状态,然后验证无论打开顺序如何,两个文件都不会针对各自的 `#p` 调用报告错误。

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript, typescript, vscode
领域
tooling
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
42/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。