PathIntellisense: path-intellisense.mappings doesn't work / not used correctly

i tried using that to solve my webpack absolute pathto autocomplete modules.

  • The projects sits on /Users/myuser/Workspace/foo.
  • The directory that I want to autocomplete is /Users/myuser/Workspace/foo/src.
  • I want to use it on my code so I can write in a file:
import Bar from 'utils/bar'

and it will be resolved to: /Users/myuser/Workspace/foo/src/utils/bar.

I tried as above:

"path-intellisense.mappings": {
    "/": "${workspaceRoot}/src"
}

what am i doing wrong ?

also - my src folder contains 10 directories that I want to be auto-mapped… do I have to add a record for each of them or it will be auto-mapped ?

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Reactions: 15
  • Comments: 33 (3 by maintainers)

Commits related to this issue

Most upvoted comments

@ChristianKohler i figured out that you can reproduce this issue by installing both path-intellisense and npm-intellisense.

I think the problem comes from npm-IntelliSense

It seems that vscode’s import path quick suggestions break mappings After I added

"typescript.quickSuggestionsForPaths": false,

and with

"path-intellisense.mappings": {
     "@": "${workspaceRoot}/app"
 }

it started to provide correct suggestions for import from '@/'

having this issue without npm-intellisense installed

absolute mapping is not working either for me. Don’t have npm intellisense extension…

Disable npm intellisense extension and add

"typescript.quickSuggestionsForPaths": false,

it works for me now

Got the same issue.

Here is my config:

"path-intellisense.mappings": {
    "/": "${workspaceRoot}/main/src",
    "controllers": "${workspaceRoot}/main/src/controllers",
    "components": "${workspaceRoot}/main/src/components"
}

When I use it with elements’ attrs it works monosnap 2017-01-27 20-51-06

image

It also works with exports image

But the only thing I need to be work – doesn’t work 😃 image

same here: trying to map my app/ directory to be used without prefix in my code:

{
    "path-intellisense.mappings": {
         "/": "${workspaceRoot}/app"
     }
}

both import '/' and import '' don’t provide suggestions

mappings not work if npm-intellisense installed

@lucasbento I am sorry. I don’t mean to order anyone to do anything. My words are inappropriate.

@ChristianKohler as you said. It is work. But is not similar behaviour as how alias in webpack work. for example.

I expect "*": "${workspaceRoot}/main/src" instead of "components": "${workspaceRoot}/main/src/components"

Then I can type whatever import x from components or import y from containers. In your case. Should I need to keep maintain project structure?

same issue and npm-intellisense isn’t installed and there is no such thing as typescript.quickSuggestionsForPaths. image image image

have anyone got any success on this ?

I got mine to work by disabling a few default path suggestions

    "typescript.suggest.paths": false,
    "javascript.suggest.paths": false,
    "path-intellisense.mappings": {
       "/": "${workspaceFolder}",
      "components" :  "${workspaceFolder}/client/src/components"
    },

Depending on which language you are working in you may have to disable the default setting {language}.suggest.paths You can make the settings specific only to a workspace which makes it more convenient.

I didn’t need to disable any other extension.

I’ve uninstalled npm-intellisense and getting same error