Auto import option to make imports relative only within current directory #45015
Labels
Awaiting More Feedback
This means we'd like to hear from more people who would be helped by this feature
Suggestion
An idea for TypeScript
Suggestion
π Search Terms
import relative
β Viability Checklist
My suggestion meets these guidelines:
β Suggestion
An option added to the
importModuleSpecifier
preference to make imports absolute if and only if their relative path would begin with../
.π Motivating Example
At my workplace, our least favourite relative imports are the ones that venture out of the current directory (i.e. they begin with any number of
../
). But there are times where we want relative imports within the current directory (i.e. beginning with./
). I don't see any existing options that support this exact style of import, includingproject-relative
.In general, the motivation for not using relative imports beginning with
../
is that it makes moving code files around more difficult.π» Use Cases
shortest
andrelative
are obviously not correct since they have no qualms about this issue.non-relative
is my current workaround, which only adds absolute imports.project-relative
I tried, but based on what I discovered and my understanding of the description in the tooltip, my guess is that it only adds absolute imports for files that are located outside of the workspace folder.The text was updated successfully, but these errors were encountered: