Description
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:
- Prior to Test for (and fix) order of import fixes #21398:
import { thing } from 'some/other/path/util';
Actual behavior:
- After Test for (and fix) order of import fixes #21398:
import { thing } from '../../other/path/util';
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 seesrc/
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