Skip to content

Commit eda7978

Browse files
committed
Cleanup getTypeParametersFromDeclaration et al
1 parent da83eb9 commit eda7978

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/compiler/checker.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6178,7 +6178,7 @@ namespace ts {
61786178
return undefined;
61796179
}
61806180

6181-
function getTypeParametersFromJSDocTemplate(declaration: SignatureDeclaration): TypeParameterDeclaration[] {
6181+
function getTypeParametersFromJSDocTemplate(declaration: DeclarationWithTypeParameters): TypeParameterDeclaration[] {
61826182
if (declaration.flags & NodeFlags.JavaScriptFile) {
61836183
const templateTag = getJSDocTemplateTag(declaration);
61846184
return templateTag && templateTag.typeParameters;
@@ -6188,9 +6188,9 @@ namespace ts {
61886188

61896189
// Return list of type parameters with duplicates removed (duplicate identifier errors are generated in the actual
61906190
// type checking functions).
6191-
function getTypeParametersFromDeclaration(typeParameterDeclarations: TypeParameterDeclaration[]): TypeParameter[] {
6191+
function getTypeParametersFromDeclaration(declaration: DeclarationWithTypeParameters): TypeParameter[] {
61926192
let result: TypeParameter[];
6193-
forEach(typeParameterDeclarations, node => {
6193+
forEach(declaration.typeParameters || getTypeParametersFromJSDocTemplate(declaration), node => {
61946194
const tp = getDeclaredTypeOfTypeParameter(node.symbol);
61956195
if (!contains(result, tp)) {
61966196
if (!result) {
@@ -6391,8 +6391,7 @@ namespace ts {
63916391
const classType = declaration.kind === SyntaxKind.Constructor ?
63926392
getDeclaredTypeOfClassOrInterface(getMergedSymbol((<ClassDeclaration>declaration.parent).symbol))
63936393
: undefined;
6394-
const typeParameters = classType ? classType.localTypeParameters :
6395-
getTypeParametersFromDeclaration(declaration.typeParameters || getTypeParametersFromJSDocTemplate(declaration));
6394+
const typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration);
63966395
const returnType = getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType);
63976396
const typePredicate = declaration.type && declaration.type.kind === SyntaxKind.TypePredicate ?
63986397
createTypePredicateFromTypePredicateNode(declaration.type as TypePredicateNode) :
@@ -8166,8 +8165,8 @@ namespace ts {
81668165
case SyntaxKind.ClassExpression:
81678166
case SyntaxKind.InterfaceDeclaration:
81688167
case SyntaxKind.TypeAliasDeclaration:
8169-
const typeParameters = (node as DeclarationWithTypeParameters).typeParameters ||
8170-
getTypeParametersFromJSDocTemplate(node as SignatureDeclaration);
8168+
const declaration = node as DeclarationWithTypeParameters;
8169+
const typeParameters = declaration.typeParameters || getTypeParametersFromJSDocTemplate(declaration);
81718170
if (typeParameters) {
81728171
for (const d of typeParameters) {
81738172
if (contains(mappedTypes, getDeclaredTypeOfTypeParameter(getSymbolOfNode(d)))) {

0 commit comments

Comments
 (0)