diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts
index 867d566b099..196bb39c6c4 100644
--- a/src/compiler/checker.ts
+++ b/src/compiler/checker.ts
@@ -11340,7 +11340,18 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
// The outer type parameters are those defined by enclosing generic classes, methods, or functions.
function getOuterTypeParametersOfClassOrInterface(symbol: Symbol): TypeParameter[] | undefined {
- const declaration = symbol.flags & SymbolFlags.Class ? symbol.valueDeclaration : getDeclarationOfKind(symbol, SyntaxKind.InterfaceDeclaration)!;
+ const declaration = (symbol.flags & SymbolFlags.Class || symbol.flags & SymbolFlags.Function)
+ ? symbol.valueDeclaration
+ : symbol.declarations?.find(decl => {
+ if (decl.kind === SyntaxKind.InterfaceDeclaration) {
+ return true;
+ }
+ if (decl.kind !== SyntaxKind.VariableDeclaration) {
+ return false;
+ }
+ const initializer = (decl as VariableDeclaration).initializer;
+ return !!initializer && (initializer.kind === SyntaxKind.FunctionExpression || initializer.kind === SyntaxKind.ArrowFunction);
+ })!;
Debug.assert(!!declaration, "Class was missing valueDeclaration -OR- non-class had no interface declarations");
return getOuterTypeParameters(declaration);
}
diff --git a/tests/cases/fourslash/quickInfoOnFunctionPropertyReturnedFromGenericFunction1.ts b/tests/cases/fourslash/quickInfoOnFunctionPropertyReturnedFromGenericFunction1.ts
new file mode 100644
index 00000000000..5005c171a03
--- /dev/null
+++ b/tests/cases/fourslash/quickInfoOnFunctionPropertyReturnedFromGenericFunction1.ts
@@ -0,0 +1,13 @@
+///
+
+//// function createProps(t: T) {
+//// function getProps() {}
+//// function createVariants() {}
+////
+//// getProps.createVariants = createVariants;
+//// return getProps;
+//// }
+////
+//// createProps({})./**/createVariants();
+
+verify.quickInfoAt("", "(property) getProps<{}>.createVariants: () => void");
diff --git a/tests/cases/fourslash/quickInfoOnFunctionPropertyReturnedFromGenericFunction2.ts b/tests/cases/fourslash/quickInfoOnFunctionPropertyReturnedFromGenericFunction2.ts
new file mode 100644
index 00000000000..8cdcc80e68c
--- /dev/null
+++ b/tests/cases/fourslash/quickInfoOnFunctionPropertyReturnedFromGenericFunction2.ts
@@ -0,0 +1,13 @@
+///
+
+//// function createProps(t: T) {
+//// const getProps = function() {}
+//// const createVariants = function() {}
+////
+//// getProps.createVariants = createVariants;
+//// return getProps;
+//// }
+////
+//// createProps({})./**/createVariants();
+
+verify.quickInfoAt("", "(property) getProps<{}>.createVariants: () => void");
diff --git a/tests/cases/fourslash/quickInfoOnFunctionPropertyReturnedFromGenericFunction3.ts b/tests/cases/fourslash/quickInfoOnFunctionPropertyReturnedFromGenericFunction3.ts
new file mode 100644
index 00000000000..ba8d14e3229
--- /dev/null
+++ b/tests/cases/fourslash/quickInfoOnFunctionPropertyReturnedFromGenericFunction3.ts
@@ -0,0 +1,13 @@
+///
+
+//// function createProps(t: T) {
+//// const getProps = () => {}
+//// const createVariants = () => {}
+////
+//// getProps.createVariants = createVariants;
+//// return getProps;
+//// }
+////
+//// createProps({})./**/createVariants();
+
+verify.quickInfoAt("", "(property) getProps<{}>.createVariants: () => void");