Vscode: Auto import not being placed correctly

Created on 9 Oct 2018  路  10Comments  路  Source: microsoft/vscode

Issue Type: Bug

I just upgraded to 28.0 from 27.2. Previously in React code, when I used the auto import feature, it would place an import line at the top of the document, e.g. import MyComponent from './MyComponent'. After upgrading to the latest version, the import line is being placed in the same line and it causes a syntax error. For example, if I try to auto import a component called MyComponent, I end up with
<import('./MyComponent').MyComponent. I tried disabling all the extensions and I had the same behavior. I read the release notes, and looked at the new settings and could not find anything related to import or import style, so I have reverted back to the old version for now.

VS Code version: Code 1.28.0 (431ef9da3cf88a7e164f9d33bf62695e07c6c2a9, 2018-10-05T14:58:53.203Z)
OS version: Windows_NT x64 10.0.15063


System Info

|Item|Value|
|---|---|
|CPUs|Intel(R) Core(TM) i7-7600U CPU @ 2.80GHz (4 x 2904)|
|GPU Status|2d_canvas: enabled
checker_imaging: disabled_off
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: enabled
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled|
|Memory (System)|15.89GB (7.84GB free)|
|Process Argv||
|Screen Reader|no|
|VM|0%|

Extensions (4)

Extension|Author (truncated)|Version
---|---|---
vscode-eslint|dba|1.6.0
prettier-vscode|esb|1.6.1
dotenv|mik|1.0.1
debugger-for-chrome|msj|4.10.2


*duplicate candidate javascript typescript upstream verified

Most helpful comment

Can we get a fix for this? This bug is extremely aggravating and does not depend on which Typescript version is used. A feature like this should be tested before publishing a major release.

All 10 comments

It seems like he is resolving properly everything but instead of adding import at the top of file, it is doing dynamic import syntax.

I've ran into the same issue, but after rollback from [email protected]. to [email protected] the problem was gone, auto import works as expected.

Same issue here, happened after 1.28.0 update.
I don't think I use typescript?
screen shot 2018-10-09 at 10 28 05 am

@amikitevich Thanks for that. I followed some instructions I found on Stack Overflow to downgrade my TypeScript version, and it's resolved for me as well.

Any non-workaround fixes? The TS version seems irrelevant to my install. The error also happens on ES6.

Could this be a duplicate of #59149, which was closed and is tracked upstream in https://github.com/Microsoft/TypeScript/issues/27317

Can we get a fix for this? This bug is extremely aggravating and does not depend on which Typescript version is used. A feature like this should be tested before publishing a major release.

For anyone else experiencing the same issue, I decided to revert back to a previous version of VS Code and it's working fine now. The only caveat is that I had to rename the directory at $HOME/Library/Application Support/Code to $HOME/Library/Application Support/Code Backup or else when I started a previous version of VS Code it would just give me a black screen.

From the "Code Backup" folder, copy your user settings from User/settings.json and you should be good to go until VS Code gets fixed.

Is there any fix for this for non Typescript devs? I only work with ES6/ES7 and I can't find a fix anywhere

Was this page helpful?
0 / 5 - 0 ratings