From 17994588b22f2e2f853f02e70ee9716135866f58 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Tue, 15 Aug 2017 11:58:57 -0700 Subject: [PATCH] Actual fix + test --- src/compiler/checker.ts | 3 +++ .../fourslash/indirectClassInstantiation.ts | 21 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 tests/cases/fourslash/indirectClassInstantiation.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index cfa76c0315..aa03332af2 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -16377,6 +16377,9 @@ namespace ts { // Note:JS inferred classes might come from a variable declaration instead of a function declaration. // In this case, using getResolvedSymbol directly is required to avoid losing the members from the declaration. let funcSymbol = checkExpression(node.expression).symbol; + if (!funcSymbol && node.expression.kind === SyntaxKind.Identifier) { + funcSymbol = getResolvedSymbol(node.expression as Identifier); + } if (funcSymbol && isDeclarationOfFunctionOrClassExpression(funcSymbol)) { funcSymbol = getSymbolOfNode((funcSymbol.valueDeclaration).initializer); } diff --git a/tests/cases/fourslash/indirectClassInstantiation.ts b/tests/cases/fourslash/indirectClassInstantiation.ts new file mode 100644 index 0000000000..c4d0d38d6e --- /dev/null +++ b/tests/cases/fourslash/indirectClassInstantiation.ts @@ -0,0 +1,21 @@ +/// + +// @allowJs: true +// @Filename: something.js +//// function TestObj(){ +//// this.property = "value"; +//// } +//// var constructor = TestObj; +//// var instance = new constructor(); +//// instance./*a*/ +//// var class2 = function() { }; +//// class2.prototype.blah = function() { }; +//// var inst2 = new class2(); +//// inst2.blah/*b*/; + +goTo.marker('a'); +verify.completionListContains('property'); +edit.backspace(); + +goTo.marker('b'); +verify.quickInfoIs('(property) class2.blah: () => void');