Skip to content

Same index export name and file name results in incorrect auto-import #40746

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Brqqq opened this issue Sep 24, 2020 · 2 comments
Closed

Same index export name and file name results in incorrect auto-import #40746

Brqqq opened this issue Sep 24, 2020 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@Brqqq
Copy link

Brqqq commented Sep 24, 2020

TypeScript Version: 4.1-dev.20200924 in VSCode 1.49.1 on Windows 10

Search Terms: auto import folder same name export

Code
Lets say you have the following folder structure:

/foo/index.ts
/entry.ts
/foo.ts

/foo/index.ts has the following contents:

export const Bar = 1;

and the other files are empty.

In /entry.ts you try typing "Bar" and use the auto-import feature.

Expected behavior:
After typing "Bar" and using the auto-import feature, the file should look like this:

import { Bar } from "./foo/";

Bar

Actual behavior:

import { Bar } from "./foo";

Bar

This import refers to /foo.ts , not /foo/index.ts

Note that if /foo.ts is not present, the actual behavior is correct.

Playground Link:

Related Issues:

@andrewbranch
Copy link
Member

Duplicate of #36730

@andrewbranch andrewbranch marked this as a duplicate of #36730 Sep 24, 2020
@andrewbranch andrewbranch added the Duplicate An existing issue was already created label Sep 24, 2020
@typescript-bot
Copy link
Collaborator

This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants