Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6634,7 +6634,7 @@ namespace ts {
// Starting with the parent of the symbol's declaration, check if the mapper maps any of
// the type parameters introduced by enclosing declarations. We just pick the first
// declaration since multiple declarations will all have the same parent anyway.
let node = symbol.declarations[0].parent;
let node: Node = symbol.declarations[0];
while (node) {
switch (node.kind) {
case SyntaxKind.FunctionType:
Expand All @@ -6654,7 +6654,7 @@ namespace ts {
case SyntaxKind.ClassExpression:
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.TypeAliasDeclaration:
const declaration = <DeclarationWithTypeParameters>node;
const declaration = node as DeclarationWithTypeParameters;
if (declaration.typeParameters) {
for (const d of declaration.typeParameters) {
if (contains(mappedTypes, getDeclaredTypeOfTypeParameter(getSymbolOfNode(d)))) {
Expand All @@ -6669,6 +6669,14 @@ namespace ts {
}
}
break;
case SyntaxKind.JSDocFunctionType:
const func = node as JSDocFunctionType;
for (const p of func.parameters) {
if (contains(mappedTypes, getTypeOfNode(p))) {
return true;
}
}
break;
case SyntaxKind.ModuleDeclaration:
case SyntaxKind.SourceFile:
return false;
Expand Down
19 changes: 19 additions & 0 deletions tests/cases/fourslash/jsDocGenerics2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
///<reference path="fourslash.ts" />
// @allowNonTsExtensions: true
// @Filename: Foo.js

/////**
//// * @param {T[]} arr
//// * @param {(function(T):T)} valuator
//// * @template T
//// */
////function SortFilter(arr,valuator)
////{
//// return arr;
////}
////var a/*1*/ = SortFilter([0, 1, 2], q/*2*/ => q);
////var b/*3*/ = SortFilter([0, 1, 2], undefined);

verify.quickInfoAt('1', "var a: number[]");
verify.quickInfoAt('2', '(parameter) q: number');
verify.quickInfoAt('3', "var b: number[]");