Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import path quick suggestions - jsconfig aliases not recognised #19113

Closed
mjbvz opened this issue Oct 11, 2017 · 7 comments
Closed

Import path quick suggestions - jsconfig aliases not recognised #19113

mjbvz opened this issue Oct 11, 2017 · 7 comments
Labels
Domain: Quick Fixes Editor-provided fixes, often called code actions. Fixed A PR has been merged for this issue Suggestion An idea for TypeScript

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Oct 11, 2017

From @mudrz on October 10, 2017 7:58

  • VSCode Version: 1.17.0
  • OS Version: macOS High Sierra 10.13

Reproduces without extensions: Yes

Doesn't work properly with aliases added in jsconfig.json https://code.visualstudio.com/docs/languages/jsconfig

Sample jsconfig.json

{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "ClientApp/*": ["./ClientApp/*"]
    }
  }
}

Expected behaviour

import Something from 'ClientApp/...'

will pull path intellisense for folder ClientApp

Existing extension path-intellisense for example can also be configured with aliases in settings.json

"path-intellisense.mappings": {
    "ClientApp": "${workspaceRoot}/MvcProject/ClientApp",
  }

Copied from original issue: microsoft/vscode#35970

@mjbvz
Copy link
Contributor Author

mjbvz commented Oct 11, 2017

Tested on TS 2.5.3 and latest TS 2.6.0 dev

I see ClientApp/* as a suggestion in this case:

Trace  - 2:35:20 PM] Response received: completions (15). Request took 4 ms. Success: true 
Result: [
    {
        "name": "ClientApp/*",
        "kind": "external module name",
        "kindModifiers": "",
        "sortText": "ClientApp/*",
        "replacementSpan": {
            "start": {
                "line": 1,
                "offset": 34
            },
            "end": {
                "line": 1,
                "offset": 34
            }
        }
    },
    {
        "name": "node",
        "kind": "external module name",
        "kindModifiers": "",
        "sortText": "node",
        "replacementSpan": {
            "start": {
                "line": 1,
                "offset": 34
            },
            "end": {
                "line": 1,
                "offset": 34
            }
        }
    },
    {
        "name": "node",
        "kind": "external module name",
        "kindModifiers": "",
        "sortText": "node",
        "replacementSpan": {
            "start": {
                "line": 1,
                "offset": 34
            },
            "end": {
                "line": 1,
                "offset": 34
            }
        }
    },
    {
        "name": "react",
        "kind": "external module name",
        "kindModifiers": "",
        "sortText": "react",
        "replacementSpan": {
            "start": {
                "line": 1,
                "offset": 34
            },
            "end": {
                "line": 1,
                "offset": 34
            }
        }
    },
    {
        "name": "react",
        "kind": "external module name",
        "kindModifiers": "",
        "sortText": "react",
        "replacementSpan": {
            "start": {
                "line": 1,
                "offset": 34
            },
            "end": {
                "line": 1,
                "offset": 34
            }
        }
    }
]

@mudrz
Copy link

mudrz commented Oct 12, 2017

I just checked, and this is what I get
screen shot 2017-10-12 at 18 58 46

I also noticed that object props Intellisense also doesn't work

Recreated the same project config here https://github.com/mudrz/jsconfig-tests

(This is TS 2.5.3, I haven't updated to TS 2.6 yet, I'll have some more time to test that in the following days)

Edit:
Intellisense works, it was a typo, but aliases don't

jsconfig.json

{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "App/*": ["./ClientApp/*"]
    }
  },
  "include": ["**/*.js"]
}

@mudrz
Copy link

mudrz commented Oct 18, 2017

I just installed TS 2.6 and it fixes the performance issues I've had, but not the aliases resolution

Updated the test project also with 2.6

How do you get this response, can you share what compilerOptions are you using

{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "App/*": ["./ClientApp/*"]
    }
  },
  "include": ["**/*.js"]
}

screen shot 2017-10-18 at 10 35 39

edit:
fyi with VS Code 1.18 the alias resolution still doesn't work correctly

@jtsom
Copy link

jtsom commented Dec 13, 2017

Not sure if anything is happening here, but this is still a big issue with latest VSCode Insiders (1.19-insiders), and Typescript@next:

ts270dev

Even trying to not use the alias results in the same bad input (ie. trying to import from 'GLOBAL/..' gives the same incorrect list of suggestions)

in tsconig.json:

    "paths": {
      "@admin/*": [ "app/admin/*" ],
      "@app/*": [ "app/*" ],
      "@coaching/*": [ "app/coaching-shared/*" ],
      "@env/*": [ "environments/*" ],
      "@wltGlobal/*": [ "GLOBAL/*" ]
    },

@adrienharnay
Copy link

adrienharnay commented Dec 13, 2017

Hey, I provided a minimal reproduction repo on this (duplicate) issue: microsoft/vscode#39983

Edit: saving you a click: https://github.com/Zephir77167/vscode-intellisense-bug

@jtsom
Copy link

jtsom commented Dec 13, 2017

The bigger issue is that even without using the path alias', VC Code has a problem if you try to do an import on an absolute path. Just try importing from 'app/ ..' and it'll show all sorts of incorrect things.

@fongandrew
Copy link

Same issue. In my case, TypeScript correctly understands the alias once the full path is set out and is able to pull exports from the file. But autocompletion on the file name returns the name of the alias itself -- e.g. if I have a path for @alias/to/file, typing @alias/ presents @alias/* (note the duplication) as an autocomplete option rathe than to/file.

This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Domain: Quick Fixes Editor-provided fixes, often called code actions. Fixed A PR has been merged for this issue Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

6 participants