-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Closed
Copy link
Labels
Fix AvailableA PR has been opened for this issueA PR has been opened for this issueNeeds InvestigationThis issue needs a team member to investigate its status.This issue needs a team member to investigate its status.
Milestone
Description
Bug Report
This appears to be recently changed behaviour. I have a package with an index.ts at the root:
- I write a file
a/Foo.ts
which containsexport const Foo = 'Foo'
- I write a root
index.ts
which containsexport * from './a/Foo'
- I write a file
b/Bar.ts
and attempt to auto-importFoo
- The import is written as
import { Foo } from '..'
.
I think that importing from an index directly above the file like this is highly likely to lead to a circular reference.
🔎 Search Terms
auto-import
auto-import relative
🕗 Version & Regression Information
- This changed between versions 4.3.5 and 4.4.2
⏯ Playground Link
See simple repro.
💻 Code
// index.ts
export * from './a/Foo';
// a/Foo.ts
export const Foo = 'Foo';
// b/Bar.ts
import { Foo } from '..'; // this is the resulting import
const Bar = Foo; // try to auto-import this
🙁 Actual behavior
Imports from parent index.ts. This file is highly likely to also import the importing file, causing a circular reference.
🙂 Expected behavior
Import from './a/Foo'
instead. Or, put another way, prefer not to import from a path which has only one or more ..
in it.
ajafff, cff3, qijinz, gluxon, lnunno and 26 morevilicvane, noobnooc, Yggdrasilqh, boenfu, rezonant and 5 more
Metadata
Metadata
Assignees
Labels
Fix AvailableA PR has been opened for this issueA PR has been opened for this issueNeeds InvestigationThis issue needs a team member to investigate its status.This issue needs a team member to investigate its status.