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

tsconfig.json path aliases are not included in auto import paths #25876

Closed
mjbvz opened this issue Jul 23, 2018 · 3 comments
Closed

tsconfig.json path aliases are not included in auto import paths #25876

mjbvz opened this issue Jul 23, 2018 · 3 comments
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue VS Code Tracked There is a VS Code equivalent to this issue

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Jul 23, 2018

From @eodrap on July 21, 2018 16:0

VS Code version: Code 1.25.1 (1dfc5e557209371715f655691b1235b6b26a06be, 2018-07-11T15:33:29.235Z)
OS version: Darwin x64 17.6.0
TypeScript version: 2.9.2
Does this issue occur when all extensions are disabled?: Yes

Steps to reproduce -

  1. Define path alias in tsconfig.json -
    "baseUrl": "./",
    "paths": {
      "@root/*": ["*"]
    },
  1. Restart VS Code
  2. Trigger auto import by typing a module name and selecting the, 'Auto import from ...' menu entry
  3. The auto import path offered does not include the alias, a relative path is inserted -
    Module path x/y/z/module.ts
    Expected path @root/x/y/z/module.ts
    Inserted path x/y/z/module.ts

Omitting the alias is causing module not found errors.

#39459 suggests this has been resolved but I cannot find a way to include the alias path prefix in auto import suggestions. I've tried setting typescript.preferences.importModuleSpecifier = 'non-relative'. Apologies if I'm missing a required preference or doing something silly.

Copied from original issue: microsoft/vscode#54798

@mjbvz
Copy link
Contributor Author

mjbvz commented Jul 23, 2018

From @vscodebot[bot] on July 21, 2018 16:0

(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

@mjbvz mjbvz self-assigned this Jul 23, 2018
@mjbvz mjbvz added Needs More Info The issue still hasn't been fully clarified Domain: JavaScript The issue relates to JavaScript specifically labels Jul 23, 2018
@mjbvz
Copy link
Contributor Author

mjbvz commented Jul 23, 2018

From @eodrap on July 23, 2018 9:33

Thanks for replying, yes it does. Clean installation & profile of VS Code Insiders, no installed extensions, and auto import paths do not include the configured alias. The alias is understood if added manually to import paths.

VS Code version: Code - Insiders 1.26.0-insider (26e5a55cd8452477bfb7a472ea9475761600adf0, 2018-07-20T05:11:33.977Z)
OS version: Darwin x64 17.6.0

@mjbvz mjbvz removed Needs More Info The issue still hasn't been fully clarified Domain: JavaScript The issue relates to JavaScript specifically labels Jul 23, 2018
@mjbvz mjbvz removed their assignment Jul 23, 2018
@mjbvz
Copy link
Contributor Author

mjbvz commented Jul 23, 2018

Confirmed this on typescript@3.1.0-dev.20180721

We always seem to use use the shorter path relative to baseUrl instead of the one configured in paths

@mjbvz mjbvz added the VS Code Tracked There is a VS Code equivalent to this issue label Jul 23, 2018
@mhegazy mhegazy added the Bug A bug in TypeScript label Jul 23, 2018
@mhegazy mhegazy assigned ghost Jul 23, 2018
@mhegazy mhegazy added this to the TypeScript 3.1 milestone Jul 23, 2018
@ghost ghost added the Fixed A PR has been merged for this issue label Jul 23, 2018
@ghost ghost closed this as completed in #25881 Jul 24, 2018
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue VS Code Tracked There is a VS Code equivalent to this issue
Projects
None yet
Development

No branches or pull requests

2 participants