From 8894915d1ac3334716c703403ecf35e8c8e0e1d2 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 18 May 2017 10:15:37 -0700 Subject: [PATCH 1/2] buildSymbolDisplay: Handle alias parentSymbol --- src/compiler/checker.ts | 6 +++--- .../fourslash/quickInfoOnMethodOfImportEquals.ts | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 tests/cases/fourslash/quickInfoOnMethodOfImportEquals.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index dde8033d1e9..aeabf816a96 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2027,7 +2027,7 @@ namespace ts { ts.forEach(symbolFromSymbolTable.declarations, isExternalModuleImportEqualsDeclaration)) { const resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); - if (isAccessible(symbolFromSymbolTable, resolveAlias(symbolFromSymbolTable))) { + if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol)) { return [symbolFromSymbolTable]; } @@ -3087,8 +3087,8 @@ namespace ts { // Write type arguments of instantiated class/interface here if (flags & SymbolFormatFlags.WriteTypeParametersOrArguments) { if (getCheckFlags(symbol) & CheckFlags.Instantiated) { - buildDisplayForTypeArgumentsAndDelimiters(getTypeParametersOfClassOrInterface(parentSymbol), - (symbol).mapper, writer, enclosingDeclaration); + const params = getTypeParametersOfClassOrInterface(symbol.flags & SymbolFlags.Alias ? resolveAlias(symbol) : symbol); + buildDisplayForTypeArgumentsAndDelimiters(params, (symbol).mapper, writer, enclosingDeclaration); } else { buildTypeParameterDisplayFromSymbol(parentSymbol, writer, enclosingDeclaration); diff --git a/tests/cases/fourslash/quickInfoOnMethodOfImportEquals.ts b/tests/cases/fourslash/quickInfoOnMethodOfImportEquals.ts new file mode 100644 index 00000000000..d4078020add --- /dev/null +++ b/tests/cases/fourslash/quickInfoOnMethodOfImportEquals.ts @@ -0,0 +1,16 @@ +/// + +// Test for https://github.com/Microsoft/TypeScript/issues/15931 + +// @Filename: /a.d.ts +////declare class C { +//// m(): void; +////} +////export = C; + +// @Filename: /b.ts +////import C = require("./a"); +////declare var x: C; +////x./**/m; + +verify.quickInfoAt("", "(method) C.m(): void", undefined); From bf7e3229cfb7a824f55ab23c03d06e8329e78946 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 23 May 2017 09:12:03 -0700 Subject: [PATCH 2/2] Fix typo: symbol -> parentSymbol --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index aeabf816a96..8df64ef4356 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3087,7 +3087,7 @@ namespace ts { // Write type arguments of instantiated class/interface here if (flags & SymbolFormatFlags.WriteTypeParametersOrArguments) { if (getCheckFlags(symbol) & CheckFlags.Instantiated) { - const params = getTypeParametersOfClassOrInterface(symbol.flags & SymbolFlags.Alias ? resolveAlias(symbol) : symbol); + const params = getTypeParametersOfClassOrInterface(parentSymbol.flags & SymbolFlags.Alias ? resolveAlias(parentSymbol) : parentSymbol); buildDisplayForTypeArgumentsAndDelimiters(params, (symbol).mapper, writer, enclosingDeclaration); } else {