-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Description
TypeScript Version: 3.0.1-insiders.20180713
Search Terms:
auto import parent relative index
Code
Screenshot taken from VS Code to illustrate; not really a "code" issue as such

Expected behavior:
Note: I am using JavaScript with jsconfig.json
Suggest a location that is a bit more specific than the index file that is probably in the middle of being parsed at the time that the import is resolved.
For example, for the following structure:
/src/index.js
/src/foo/index.js
/src/foo/Foo.js
/src/bar/index.js
/src/bar/Bar.js
While editing Bar, a reference to Foo should resolve as ../foo or ../foo/Foo. At the very least, I should be given the option to resolve it as such. In general, it'd be nice to be able to avoid blind linking to a local or ancestral index.js file via just .. or ..
Actual behavior:
Auto-import is suggesting .. as the path to the file (also can occur with just .). This can cause issues with eagerly-evaluated exports that resolve at parse time - linking to an index file that is in the middle of being parsed can create issues. It also feels kind of sloppy to just point at the parent and hope for the best. In any case, it would be nice if TypeScript could avoid assuming that the developer prefers one style of relative path resolution over another.
Playground Link: n/a
Related Issues: Only issues related to the '../../../../../@xxxxx/....' bug
EDIT: I'm wondering if this is a bug, because I'm noticing most other imports behaving the way I expect. The issue I described above is occurring on a new file I added. I don't know if it's relevant, but the in addition to some wildcard exports, the parent index file also has some stopgap imports and exports implemented directly in that file.