microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
99.26k stars 12.31k forks source link

"delete all unused declarations" really only deletes declarations #24789

Closed mjbvz closed 6 years ago

mjbvz commented 6 years ago

From @alexfung888 on June 8, 2018 4:34

Issue Type: Bug

let useless = true;
useless = false;

VSCode notices that the variable is never read. It will offer to delete the declaration (the first line), but it won't delete the second line. Then user will need to hunt down all the updates, which are now flagged in red as cannot fine name 'useless'

VS Code version: Code 1.24.0 (6a6e02cef0f2122ee1469765b704faf5d0e0d859, 2018-06-06T17:35:40.560Z) OS version: Windows_NT x64 10.0.17134

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz (8 x 3392)| |GPU Status|2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
rasterization: disabled_software
video_decode: enabled
video_encode: enabled
vpx_decode: unavailable_software
webgl: enabled
webgl2: enabled| |Memory (System)|7.88GB (1.01GB free)| |Process Argv|C:\Program Files\Microsoft VS Code\Code.exe| |Screen Reader|no| |VM|0%|
Extensions (13) Extension|Author (truncated)|Version ---|---|--- path-intellisense|chr|1.4.2 githistory|don|0.4.1 EditorConfig|Edi|0.12.4 tslint|eg2|1.0.30 Angular2|joh|6.1.1 azure-account|ms-|0.4.0 PowerShell|ms-|1.7.0 debugger-for-chrome|msj|4.5.0 angular2-inline|nat|0.0.17 vscode-docker|Pet|0.0.27 ejs-language-support|Qas|0.0.1 vscode-bolt-language|smk|0.0.4 autoimport|ste|1.5.3

Copied from original issue: Microsoft/vscode#51416

mjbvz commented 6 years ago

From @alexfung888 on June 8, 2018 5:8

Actually the same happens to function parameters. When VSCode deletes the unused parameters for you, you will need hunt down all the callers to fix their parameter list, hoping that it will no longer match the signature.

In this pathetic case, the behaviour will change after b is removed, and the author may not even notice!

private f (a: number, b: number, c?: number) {
  return c ? 42 : a;
}
f(3, 5);
ghost commented 6 years ago

Reopening for the parameter part.