Skip to content

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

@mjbvz

Description

@mjbvz

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issueVS Code TrackedThere is a VS Code equivalent to this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions