Skip to content

Incorrect kind for path completions when using compilerOptions.paths #21582

Closed
@mjbvz

Description

@mjbvz

From microsoft/vscode#41458

TypeScript Version: 2.7.1

Search Terms:

  • Path intellisense
  • Path completions

Code

$ git clone https://github.com/mjbvz/ts-issue-21582
  1. For a js project:
jsconfig.json
src/
  index.js
  keeper.js
  animals/
      cat.js

With jsconfig.json:

{
	"compilerOptions": {
		"module": "commonjs",
		"target": "es2016",
		"baseUrl": ".",
		"paths": {
			"@zoo/*": ["./src/*"]
		}
	},
	"exclude": [
		"node_modules",
		"**/node_modules/*"
	]
}
  1. In src/index.js, type: import {} from '@zoo/'

  2. Trigger path intellisense after @zoo/

Expected behavior:
Returns two completions, one for the file keeper and one for the directory animals. These should have kinds of script and directory respectively. This is in fact what happens for path completions on import {} from './':

Result: [
    {
        "name": "animals",
        "kind": "directory",
        "kindModifiers": "",
        "sortText": "animals",
        "replacementSpan": {
            "start": {
                "line": 2,
                "offset": 19
            },
            "end": {
                "line": 2,
                "offset": 19
            }
        }
    },
    {
        "name": "keeper",
        "kind": "script",
        "kindModifiers": "",
        "sortText": "keeper",
        "replacementSpan": {
            "start": {
                "line": 2,
                "offset": 19
            },
            "end": {
                "line": 2,
                "offset": 19
            }
        }
    }
]

Actual behavior:
Correct suggestions returned but both have "kind": "external module name"

[Trace  - 12:50:32 PM] Response received: completions (36). Request took 4 ms. Success: true 
Result: [
    {
        "name": "index",
        "kind": "external module name",
        "kindModifiers": "",
        "sortText": "index",
        "replacementSpan": {
            "start": {
                "line": 1,
                "offset": 22
            },
            "end": {
                "line": 1,
                "offset": 22
            }
        }
    },
    {
        "name": "keeper",
        "kind": "external module name",
        "kindModifiers": "",
        "sortText": "keeper",
        "replacementSpan": {
            "start": {
                "line": 1,
                "offset": 22
            },
            "end": {
                "line": 1,
                "offset": 22
            }
        }
    }
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issueVS Code TrackedThere is a VS Code equivalent to this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions