Fix bug: get merged symbol of symbol.parent before checking against module symbol (#21147)

This commit is contained in:
Andy
2018-01-11 13:42:08 -08:00
committed by GitHub
parent e3da8fb526
commit 269867f5e8
2 changed files with 22 additions and 1 deletions

View File

@@ -1200,7 +1200,7 @@ namespace ts.Completions {
// Don't add a completion for a re-export, only for the original.
// 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 (symbol.parent !== typeChecker.resolveExternalModuleSymbol(moduleSymbol)
if (typeChecker.getMergedSymbol(symbol.parent) !== typeChecker.resolveExternalModuleSymbol(moduleSymbol)
|| some(symbol.declarations, d => isExportSpecifier(d) && !!d.parent.parent.moduleSpecifier)) {
continue;
}

View File

@@ -0,0 +1,21 @@
/// <reference path="fourslash.ts" />
// @Filename: /b.d.ts
////declare namespace N {
//// export const foo: number;
////}
////declare module "n" {
//// export = N;
////}
// @Filename: /c.d.ts
////declare namespace N {}
// @Filename: /a.ts
////fo/**/
goTo.marker("");
verify.completionListContains({ name: "foo", source: "n" }, "const N.foo: number", "", "const", undefined, /*hasAction*/ true, {
includeExternalModuleExports: true,
sourceDisplay: "n",
});