mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-14 09:49:40 -05:00
Support import completions for a re-export with a different name from the original (#28055)
This commit is contained in:
@@ -1410,7 +1410,7 @@ namespace ts.Completions {
|
||||
// If `symbol.parent !== ...`, this comes from an `export * from "foo"` re-export. Those don't create new symbols.
|
||||
// If `some(...)`, this comes from an `export { foo } from "foo"` re-export, which creates a new symbol (thus isn't caught by the first check).
|
||||
if (typeChecker.getMergedSymbol(symbol.parent!) !== resolvedModuleSymbol
|
||||
|| some(symbol.declarations, d => isExportSpecifier(d) && !!d.parent.parent.moduleSpecifier)) {
|
||||
|| some(symbol.declarations, d => isExportSpecifier(d) && !d.propertyName && !!d.parent.parent.moduleSpecifier)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,9 +12,13 @@
|
||||
/////**/
|
||||
|
||||
goTo.marker("");
|
||||
verify.completionListContains({ name: "x", source: "/a" }, "const x: 0", "", "const", /*spanIndex*/ undefined, /*hasAction*/ true, {
|
||||
includeCompletionsForModuleExports: true,
|
||||
sourceDisplay: "./a",
|
||||
verify.completions({
|
||||
marker: "",
|
||||
includes: [
|
||||
{ name: "x", source: "/a", sourceDisplay: "./a", text: "const x: 0", hasAction: true },
|
||||
{ name: "y", source: "/index", sourceDisplay: ".", text: "(alias) const y: 0\nexport y", hasAction: true },
|
||||
],
|
||||
preferences: { includeCompletionsForModuleExports: true },
|
||||
});
|
||||
|
||||
verify.applyCodeActionFromCompletion("", {
|
||||
@@ -25,3 +29,12 @@ verify.applyCodeActionFromCompletion("", {
|
||||
|
||||
`,
|
||||
});
|
||||
verify.applyCodeActionFromCompletion("", {
|
||||
name: "y",
|
||||
source: "/index",
|
||||
description: `Import 'y' from module "."`,
|
||||
newFileContent: `import { x } from "./a";
|
||||
import { y } from ".";
|
||||
|
||||
`,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user