@@ -6178,24 +6178,24 @@ namespace ts {
6178
6178
return undefined;
6179
6179
}
6180
6180
6181
- function getTypeParametersFromJSDocTemplate(declaration: SignatureDeclaration): TypeParameter [] {
6181
+ function getTypeParametersFromJSDocTemplate(declaration: SignatureDeclaration): TypeParameterDeclaration [] {
6182
6182
if (declaration.flags & NodeFlags.JavaScriptFile) {
6183
6183
const templateTag = getJSDocTemplateTag(declaration);
6184
- if (templateTag) {
6185
- return getTypeParametersFromDeclaration(templateTag.typeParameters);
6186
- }
6184
+ return templateTag && templateTag.typeParameters;
6187
6185
}
6188
-
6189
6186
return undefined;
6190
6187
}
6191
6188
6192
6189
// Return list of type parameters with duplicates removed (duplicate identifier errors are generated in the actual
6193
6190
// type checking functions).
6194
6191
function getTypeParametersFromDeclaration(typeParameterDeclarations: TypeParameterDeclaration[]): TypeParameter[] {
6195
- const result: TypeParameter[] = [];
6192
+ let result: TypeParameter[];
6196
6193
forEach(typeParameterDeclarations, node => {
6197
6194
const tp = getDeclaredTypeOfTypeParameter(node.symbol);
6198
6195
if (!contains(result, tp)) {
6196
+ if (!result) {
6197
+ result = [];
6198
+ }
6199
6199
result.push(tp);
6200
6200
}
6201
6201
});
@@ -6392,8 +6392,7 @@ namespace ts {
6392
6392
getDeclaredTypeOfClassOrInterface(getMergedSymbol((<ClassDeclaration>declaration.parent).symbol))
6393
6393
: undefined;
6394
6394
const typeParameters = classType ? classType.localTypeParameters :
6395
- declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) :
6396
- getTypeParametersFromJSDocTemplate(declaration);
6395
+ getTypeParametersFromDeclaration(declaration.typeParameters || getTypeParametersFromJSDocTemplate(declaration));
6397
6396
const returnType = getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType);
6398
6397
const typePredicate = declaration.type && declaration.type.kind === SyntaxKind.TypePredicate ?
6399
6398
createTypePredicateFromTypePredicateNode(declaration.type as TypePredicateNode) :
@@ -8167,9 +8166,10 @@ namespace ts {
8167
8166
case SyntaxKind.ClassExpression:
8168
8167
case SyntaxKind.InterfaceDeclaration:
8169
8168
case SyntaxKind.TypeAliasDeclaration:
8170
- const declaration = node as DeclarationWithTypeParameters;
8171
- if (declaration.typeParameters) {
8172
- for (const d of declaration.typeParameters) {
8169
+ const typeParameters = (node as DeclarationWithTypeParameters).typeParameters ||
8170
+ getTypeParametersFromJSDocTemplate(node as SignatureDeclaration);
8171
+ if (typeParameters) {
8172
+ for (const d of typeParameters) {
8173
8173
if (contains(mappedTypes, getDeclaredTypeOfTypeParameter(getSymbolOfNode(d)))) {
8174
8174
return true;
8175
8175
}
0 commit comments