microsoft / microsoft/TypeScript

[TypeScript] Rename Symbol doesn't work as expected with Declaration Merging

Open
#62,065 7 comments 0 reactions 0 assignees View on GitHub
Needs Investigation
Dominant language
Go
Stars
111k
Forks
14.3k
PR merge metrics
PR metrics pending

Description

Type: Bug

Does this issue occur when all extensions are disabled?: Yes

When renaming symbols in TypeScript, the feature doesn't take into account declaration merging. As a result, renaming symbols breaks references. Renaming the subsequent symbols to match does not fix the references. Whether the imports are explicit or default seems to have no effect.

Steps to Reproduce:

1. Create a class and a namespace with the same name, export them
2. Import the merged symbol in another file, use references to both the class and namespace
3. Attempt to rename the original class & namespace without breaking the references

```typescript
// file: MyWonderfulClass.class.ts
export class MyWonderfulClass {
// Absolutely wonderful things
}

export namespace MyWonderfulClass {
export interface MyWonderfulClassType {}
}

export default MyWonderfulClass;

```

```typescript
// file: script.ts
import MyWonderfulClass from "./MyWonderfulClass.class";

const inst = new MyWonderfulClass();
const obj: MyWonderfulClass.MyWonderfulClassType = {};

```

VS Code version: Code 1.102.0 (cb0c47c0cfaad0757385834bd89d410c78a856c0, 2025-07-09T22:10:34.600Z)
OS version: Windows_NT x64 10.0.26100
Modes:
Remote OS version: Linux x64 6.6.87.2-microsoft-standard-WSL2

System Info

|Item|Value|
|---|---|
|CPUs|13th Gen Intel(R) Core(TM) i9-13900K (32 x 2995)|
|GPU Status|2d_canvas: enabled
canvas_oop_rasterization: enabled_on
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
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off|
|Load (avg)|undefined|
|Memory (System)|63.72GB (42.33GB free)|
|Process Argv|--crash-reporter-id cbb68604-7b21-4289-9c14-7e1fc2a74fab|
|Screen Reader|no|
|VM|0%|

|Item|Value|
|---|---|
|Remote|WSL: Ubuntu|
|OS|Linux x64 6.6.87.2-microsoft-standard-WSL2|
|CPUs|13th Gen Intel(R) Core(TM) i9-13900K (32 x 0)|
|Memory (System)|31.20GB (29.24GB free)|
|VM|0%|
Extensions (35)

Extension|Author (truncated)|Version
---|---|---
vscode-tailwindcss|bra|0.14.25
vscode-modelines|chr|2.0.6
vscode-css-modules|cli|0.5.4
vscode-eslint|dba|3.0.10
es7-react-js-snippets|dsz|4.4.3
gitlens|eam|17.3.0
vscode-html-css|ecm|2.0.13
vscode-great-icons|emm|2.1.119
php-intellisense|fel|2.3.14
vscode-firefox-debug|fir|2.15.0
auto-rename-tag|for|0.1.10
vscode-github-actions|git|0.27.2
go|gol|0.48.0
todo-tree|Gru|0.0.226
beautify|Hoo|1.5.0
rest-client|hum|0.25.1
git-graph|mhu|1.30.0
vscode-containers|ms-|2.0.3
vscode-docker|ms-|2.0.0
vscode-edge-devtools|ms-|2.1.9
remote-containers|ms-|0.422.0
remote-ssh|ms-|0.120.0
remote-ssh-edit|ms-|0.87.0
remote-wsl|ms-|0.99.0
vscode-remote-extensionpack|ms-|0.26.0
cpptools|ms-|1.26.3
powershell|ms-|2025.2.0
remote-explorer|ms-|0.5.0
remote-server|ms-|1.5.2
prisma|Pri|6.11.1
perl|ric|2.6.2
vscode-icons|vsc|12.13.0
vscode-nginx|wil|0.7.2
php-pack|xde|1.0.3
html-css-class-completion|Zig|1.20.0

A/B Experiments

```
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805:30301674
binariesv615:30325510
vsaa593cf:30376535
py29gd2263:31024239
vscaat:30438848
c4g48928:30535728
azure-dev_surveyone:30548225
vscrp:30673768
962ge761:30959799
pythongtdpath:30769146
welcomedialog:30910333
pythonnoceb:30805159
asynctok:30898717
pythonmypyd1:30879173
h48ei257:31000450
pythontbext0:30879054
accentitlementsc:30995553
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
dsvsc021:30996838
945dj816:31013170
a69g1124:31058053
dvdeprecation:31068756
dwnewjupytercf:31046870
newcmakeconfigv2:31071590
impr_priority:31102340
nativerepl2:31139839
refactort:31108082
pythonrstrctxt:31112756
flightc:31134773
wkspc-onlycs-t:31132770
wkspc-ranged-c:31125598
fje88620:31121564
notype1:31143045
cc771715:31140165

```

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue using MyWonderfulClass.class.ts and script.ts, following the three declaration-merging steps in the report. Then trace the Rename Symbol entry point for this case and verify that references to both the class and namespace remain valid after renaming; the issue is done when the imported instance and MyWonderfulClass.MyWonderfulClassType references still resolve.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.