Refactor "Move to a new file" does not honor explicit file extensions #52886
Labels
Bug
A bug in TypeScript
Domain: Refactorings
e.g. extract to constant or function, rename symbol
Help Wanted
You can do this
Milestone
Type: Bug
When working on a ESM project, file extensions of imported paths need to be "explicit". In other words you need to write e.g.
import * from "./somefile.js"
(notice the.js
at the end).When the cursor is at a type or class, open the refactor menu (Ctrl+Shift+R) and select "Move to a new file".
Notice how the file then is automatically imported:
This will only be a valid import if the
--moduleResolution
is not set tonode16
ornodenext
. When you are working on a ESM project, you'll get the following compiler error:System info (generated from "Report Issue" button in VSCode):
VS Code version: Code 1.74.3 (97dec172d3256f8ca4bfb2143f3f76b503ca0534, 2023-01-09T16:57:40.428Z)
OS version: Linux x64 6.0.12-76060006-generic
Modes:
Sandboxed: No
Remote OS version: Linux x64 5.4.0-131-generic
System Info
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
skia_renderer: enabled_on
video_decode: disabled_software
video_encode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
Extensions (16)
(1 theme extensions excluded)
A/B Experiments
The text was updated successfully, but these errors were encountered: