Skip to content

De-prioritize "./index" when picking auto-import path from within the same folder  #23598

@mhegazy

Description

@mhegazy

Consider a file structure as such:

|   tsconfig.json
|
\---src
        a.ts
        foo.ts
        index.ts
// src/index.ts

export * from "./foo";
// src/foo.ts

export const foo = 0;

in a.ts, completion for imported foo adds:

import { foo } from ".";

foo;

It seems that . or ./index is the wrong choice here. most likely users want to get to the local implementation in the same folder.

on the other hand, an external library, you want the index instead.. e.g.:

import { Subject} from ""rxjs"";

and not

import { Subject} from ""rxjs/Subject"";

Related: #23410

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: LS: Completion ListsThe issue relates to showing completion lists in an editorDomain: LS: Quick FixesEditor-provided fixes, often called code actions.FixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions