Skip to content

Import fix suggestions are traversing upwards after #21398 #22249

Closed
@alextreppass

Description

@alextreppass

TypeScript Version: 2.7.2

Search Terms: autoimport import fix relative paths baseUrl

Code

In our codebase, we have the compiler option baseUrl set to ./src. We have no other path-related settings.

Given the following files:

  • src/some/path/to/consumer.ts
  • src/some/other/path/util.ts

When editing consumer.ts to import a member of util.ts, VSCode will suggest and import the following:

Expected behavior:

Actual behavior:

It looks like the change by @Andy-MS was to fix #19920, but I am unable to configure paths and/or rootDirs in a way that brings back the old behaviour here.

Restrictions:

  • I can't change the baseUrl to "./" as we don't want to see src/ prepended to our imports
  • We need the full path (just without src/) for easy grepping and refactoring

I've tested a revert of d333d88 against current TypeScript master (ec249f7 at the time of writing) and can confirm the old behaviour comes back.

If it's by design, any chance this logic could be tweaked to take into account some combination of "baseUrl": "./src" with paths and/or rootDirs? Or the behaviour made configurable via some other mechanism?

Working with ../../../../... in a large and fast-moving codebase is hard.

Related Issues:
#19920
microsoft/vscode#44699

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions