Skip to content

Commit 1785041

Browse files
authored
make getEffectiveTypeParameterDeclarations public (#25472)
1 parent bb57c5a commit 1785041

File tree

3 files changed

+25
-20
lines changed

3 files changed

+25
-20
lines changed

src/compiler/utilities.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3351,21 +3351,6 @@ namespace ts {
33513351
return node.type || (isInJavaScriptFile(node) ? getJSDocReturnType(node) : undefined);
33523352
}
33533353

3354-
/**
3355-
* Gets the effective type parameters. If the node was parsed in a
3356-
* JavaScript file, gets the type parameters from the `@template` tag from JSDoc.
3357-
*/
3358-
export function getEffectiveTypeParameterDeclarations(node: DeclarationWithTypeParameters): ReadonlyArray<TypeParameterDeclaration> {
3359-
if (isJSDocSignature(node)) {
3360-
return emptyArray;
3361-
}
3362-
if (isJSDocTypeAlias(node)) {
3363-
Debug.assert(node.parent.kind === SyntaxKind.JSDocComment);
3364-
return flatMap(node.parent.tags, tag => isJSDocTemplateTag(tag) ? tag.typeParameters : undefined) as ReadonlyArray<TypeParameterDeclaration>;
3365-
}
3366-
return node.typeParameters || (isInJavaScriptFile(node) ? getJSDocTypeParameterDeclarations(node) : emptyArray);
3367-
}
3368-
33693354
export function getJSDocTypeParameterDeclarations(node: DeclarationWithTypeParameters): ReadonlyArray<TypeParameterDeclaration> {
33703355
return flatMap(getJSDocTags(node), tag => isNonTypeAliasTemplate(tag) ? tag.typeParameters : undefined);
33713356
}
@@ -5053,6 +5038,21 @@ namespace ts {
50535038
export function getAllJSDocTagsOfKind(node: Node, kind: SyntaxKind): ReadonlyArray<JSDocTag> {
50545039
return getJSDocTags(node).filter(doc => doc.kind === kind);
50555040
}
5041+
5042+
/**
5043+
* Gets the effective type parameters. If the node was parsed in a
5044+
* JavaScript file, gets the type parameters from the `@template` tag from JSDoc.
5045+
*/
5046+
export function getEffectiveTypeParameterDeclarations(node: DeclarationWithTypeParameters): ReadonlyArray<TypeParameterDeclaration> {
5047+
if (isJSDocSignature(node)) {
5048+
return emptyArray;
5049+
}
5050+
if (isJSDocTypeAlias(node)) {
5051+
Debug.assert(node.parent.kind === SyntaxKind.JSDocComment);
5052+
return flatMap(node.parent.tags, tag => isJSDocTemplateTag(tag) ? tag.typeParameters : undefined) as ReadonlyArray<TypeParameterDeclaration>;
5053+
}
5054+
return node.typeParameters || (isInJavaScriptFile(node) ? getJSDocTypeParameterDeclarations(node) : emptyArray);
5055+
}
50565056
}
50575057

50585058
// Simple node tests of the form `node.kind === SyntaxKind.Foo`.

tests/baselines/reference/api/tsserverlibrary.d.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6470,11 +6470,6 @@ declare namespace ts {
64706470
* JavaScript file, gets the return type annotation from JSDoc.
64716471
*/
64726472
function getEffectiveReturnTypeNode(node: SignatureDeclaration | JSDocSignature): TypeNode | undefined;
6473-
/**
6474-
* Gets the effective type parameters. If the node was parsed in a
6475-
* JavaScript file, gets the type parameters from the `@template` tag from JSDoc.
6476-
*/
6477-
function getEffectiveTypeParameterDeclarations(node: DeclarationWithTypeParameters): ReadonlyArray<TypeParameterDeclaration>;
64786473
function getJSDocTypeParameterDeclarations(node: DeclarationWithTypeParameters): ReadonlyArray<TypeParameterDeclaration>;
64796474
/**
64806475
* Gets the effective type annotation of the value parameter of a set accessor. If the node
@@ -6787,6 +6782,11 @@ declare namespace ts {
67876782
function getJSDocTags(node: Node): ReadonlyArray<JSDocTag>;
67886783
/** Gets all JSDoc tags of a specified kind, or undefined if not present. */
67896784
function getAllJSDocTagsOfKind(node: Node, kind: SyntaxKind): ReadonlyArray<JSDocTag>;
6785+
/**
6786+
* Gets the effective type parameters. If the node was parsed in a
6787+
* JavaScript file, gets the type parameters from the `@template` tag from JSDoc.
6788+
*/
6789+
function getEffectiveTypeParameterDeclarations(node: DeclarationWithTypeParameters): ReadonlyArray<TypeParameterDeclaration>;
67906790
}
67916791
declare namespace ts {
67926792
function isNumericLiteral(node: Node): node is NumericLiteral;

tests/baselines/reference/api/typescript.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3237,6 +3237,11 @@ declare namespace ts {
32373237
function getJSDocTags(node: Node): ReadonlyArray<JSDocTag>;
32383238
/** Gets all JSDoc tags of a specified kind, or undefined if not present. */
32393239
function getAllJSDocTagsOfKind(node: Node, kind: SyntaxKind): ReadonlyArray<JSDocTag>;
3240+
/**
3241+
* Gets the effective type parameters. If the node was parsed in a
3242+
* JavaScript file, gets the type parameters from the `@template` tag from JSDoc.
3243+
*/
3244+
function getEffectiveTypeParameterDeclarations(node: DeclarationWithTypeParameters): ReadonlyArray<TypeParameterDeclaration>;
32403245
}
32413246
declare namespace ts {
32423247
function isNumericLiteral(node: Node): node is NumericLiteral;

0 commit comments

Comments
 (0)