microsoft / microsoft/TypeScript

"javascript.preferences.importModuleSpecifier" relative path, but with current directory prefix

Open
#40,442 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Awaiting More Feedback Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

I'm not sure if there is a way to do this already, but I tried so many different setting combinations without any success, so it would be nice to have an option to prefix relative import paths with ./, either as part of the importModuleSpecifier or somewhere else.

So it would go from this:

import FML from '../components/FML'

To this (optional of course, not changing the default behaviour):

import FML from './../components/FML'

I accidentally posted this in the TypeScript Repository first, so here's the original (now deleted) post explaining this further:

I'm having trouble getting the autoimport feature to include ./ at the start of the path for local imports. I tried changing all the settings mentioned above and more to all the possible options and I tried setting it with jsconfig.json - tried pretty much all the possible combinations of these settings - but I just can't get it to work.

The closest I got was the default setting, which made the import paths like this import FML from '../components/FML', but I still have to manually put the ./ before each import path to change it to this import FML from './../components/FML' :( Can anyone help me please (if so, you can send me a mail to not clutter up this post)?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files or tests are named. Start by searching for the javascript.preferences.importModuleSpecifier setting and the autoimport path-generation entry point; done means an optional setting produces local relative imports with the requested ./ prefix without changing the default behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, vscode
Domain
developer-experience, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.