Incorrect Typescript imports in VSCode for MacOS
Asked Answered
V

1

6

In VSCode, auto imports are not correct on MacOS.

This is what I see when referring to an unimported module in VSCode.

pop up by vs code

However, the file path is incorrect. This path assumes that the file is located at the root of the project which is not true.

This is how the import from constants folder needs to be, and this is what VSCode adds:

incorrectly imported module

According to my friend, this works perfectly on Ubuntu. I haven't added any special marketplace packages that give this feature, AFAIK.

What could be the problem?

Voorhees answered 15/7, 2019 at 19:23 Comment(1)
I'm having same issueHorner
B
10

Had the same issue. Go to File > Preferences > settings and type "Import Module Specifier" in the searchbox.

Then set the option TypeScript › Preferences: Import Module Specifier to relative:

enter image description here

Barring answered 21/7, 2020 at 6:24 Comment(2)
Can we do this for JavaScript?Dougald
I would say yes. Just use the setting "JavaScript > Preferences: Import Module Specifier" and set it to "relative".Barring

© 2022 - 2024 — McMap. All rights reserved.