Skip to content

Odd file completion for file in subdirectory returned when using compilerOptions.path #21590

Closed
@mjbvz

Description

@mjbvz

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/animals/'

  2. Trigger path intellisense after @zoo/animals/

Expected behavior:
Returns a file completion for `cat.

Actual behavior:
An odd completion for /cat is returned:

[Trace  - 2:30:56 PM] Response received: completions (470). Request took 4 ms. Success: true 
Result: [
    {
        "name": "/cat",
        "kind": "external module name",
        "kindModifiers": "",
        "sortText": "/cat",
        "replacementSpan": {
            "start": {
                "line": 1,
                "offset": 30
            },
            "end": {
                "line": 1,
                "offset": 30
            }
        }
    }
]

This causes the import to become '@zoo/animals//cat'

Related:
#21589
#21591

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions