-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Closed
Copy link
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: LS: Completion ListsThe issue relates to showing completion lists in an editorThe issue relates to showing completion lists in an editorHelp WantedYou can do thisYou can do this
Milestone
Description
Bug Report
π Search Terms
import statement completion
auto import
π Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ and non seems to apply
β― Playground Link
Playground and bug workbench both don't seem to support import statement completion so I created a repo for the reproduction.
https://github.com/jasonlyu123/import-statement-completion-dollar-sign-repro. But the reproduction is simple so it might be faster to just create the file in the editor.
π» Code
// @filename: $another.ts
export function another() {
}
// @filename: imported.ts
import ano // trigger completion herefourslash test case
/// <reference path="fourslash.ts" />
// @Filename: /$another.ts
//// export function another() {}
// @Filename: /imported.ts
//// [|import ano/*0*/|]
////
verify.completions({
marker: `0`,
isNewIdentifierLocation: true,
exact: [{
name: "another",
source: "./$another",
sourceDisplay: "./$another",
insertText: `import { another$1 } from "./\\$another"`,
isSnippet: true,
replacementSpan: test.ranges()[0],
}, {
name: "type",
sortText: completion.SortText.GlobalsOrKeywords,
}],
preferences: {
includeCompletionsForImportStatements: true,
includeCompletionsForModuleExports: true,
includeCompletionsWithSnippetText: true,
includeCompletionsWithInsertText: true,
},
});π Actual behavior
The module specifier is not escaped so when you accept the suggestion the word that starts with $ got cut off.
For example:
./$another => ./
$lib/path/to => /path/to
The real-world use case is that SvelteKit has some module/alias that contains $ like $app/enviroment and $lib
π Expected behavior
The module specifier is correctly inserted.
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: LS: Completion ListsThe issue relates to showing completion lists in an editorThe issue relates to showing completion lists in an editorHelp WantedYou can do thisYou can do this